admin_role_test.rb 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. # encoding: utf-8
  2. require 'browser_test_helper'
  3. class AdminRoleTest < TestCase
  4. def test_role
  5. name = "some role #{rand(99_999_999)}"
  6. @browser = browser_instance
  7. login(
  8. username: 'master@example.com',
  9. password: 'test',
  10. url: browser_url,
  11. )
  12. tasks_close_all()
  13. rand = rand(99_999_999).to_s
  14. login = 'agent-role-' + rand
  15. firstname = 'Role' + rand
  16. lastname = 'Module' + rand
  17. email = 'agent-role-' + rand + '@example.com'
  18. password = 'agentpw'
  19. user_create(
  20. data: {
  21. login: login,
  22. firstname: firstname,
  23. lastname: lastname,
  24. email: email,
  25. password: password,
  26. },
  27. )
  28. name = "somerole#{rand}"
  29. role_create(
  30. data: {
  31. name: name,
  32. default_at_signup: false,
  33. permission: [
  34. 'admin.group',
  35. 'user_preferences.device',
  36. ],
  37. member: [login],
  38. }
  39. )
  40. logout()
  41. login(
  42. username: email,
  43. password: password,
  44. url: browser_url,
  45. )
  46. tasks_close_all()
  47. click(css: 'a[href="#current_user"]')
  48. click(css: 'a[href="#profile"]')
  49. match(
  50. css: '.content .NavBarProfile',
  51. value: 'Password',
  52. )
  53. match(
  54. css: '.content .NavBarProfile',
  55. value: 'Language',
  56. )
  57. match_not(
  58. css: '.content .NavBarProfile',
  59. value: 'Notifications',
  60. )
  61. match_not(
  62. css: '.content .NavBarProfile',
  63. value: 'Calendar',
  64. )
  65. match_not(
  66. css: '.content .NavBarProfile',
  67. value: 'Token Access',
  68. )
  69. match(
  70. css: '.content .NavBarProfile',
  71. value: 'Devices',
  72. )
  73. logout()
  74. login(
  75. username: 'master@example.com',
  76. password: 'test',
  77. url: browser_url,
  78. )
  79. role_edit(
  80. data: {
  81. name: name,
  82. active: false,
  83. }
  84. )
  85. logout()
  86. login(
  87. username: email,
  88. password: password,
  89. url: browser_url,
  90. )
  91. tasks_close_all()
  92. click(css: 'a[href="#current_user"]')
  93. click(css: 'a[href="#profile"]')
  94. match(
  95. css: '.content .NavBarProfile',
  96. value: 'Password',
  97. )
  98. match(
  99. css: '.content .NavBarProfile',
  100. value: 'Language',
  101. )
  102. match_not(
  103. css: '.content .NavBarProfile',
  104. value: 'Notifications',
  105. )
  106. match_not(
  107. css: '.content .NavBarProfile',
  108. value: 'Calendar',
  109. )
  110. match_not(
  111. css: '.content .NavBarProfile',
  112. value: 'Token Access',
  113. )
  114. match_not(
  115. css: '.content .NavBarProfile',
  116. value: 'Devices',
  117. )
  118. end
  119. end