PageRenderTime 24ms CodeModel.GetById 10ms RepoModel.GetById 0ms app.codeStats 0ms

/features/steps/admin/users.rb

https://gitlab.com/zarevavasyl/gitlab-ce
Ruby | 167 lines | 132 code | 35 blank | 0 comment | 0 complexity | a3558c768cee80e9165d2bbf3909083a MD5 | raw file
  1. class Spinach::Features::AdminUsers < Spinach::FeatureSteps
  2. include SharedAuthentication
  3. include SharedPaths
  4. include SharedAdmin
  5. before do
  6. allow(Gitlab::OAuth::Provider).to receive(:providers).and_return([:twitter, :twitter_updated])
  7. allow_any_instance_of(ApplicationHelper).to receive(:user_omniauth_authorize_path).and_return(root_path)
  8. end
  9. after do
  10. allow(Gitlab::OAuth::Provider).to receive(:providers).and_call_original
  11. allow_any_instance_of(ApplicationHelper).to receive(:user_omniauth_authorize_path).and_call_original
  12. end
  13. step 'I should see all users' do
  14. User.all.each do |user|
  15. expect(page).to have_content user.name
  16. end
  17. end
  18. step 'Click edit' do
  19. @user = User.first
  20. find("#edit_user_#{@user.id}").click
  21. end
  22. step 'Input non ascii char in username' do
  23. fill_in 'user_username', with: "\u3042\u3044"
  24. end
  25. step 'Click save' do
  26. click_button("Save")
  27. end
  28. step 'See username error message' do
  29. page.within "#error_explanation" do
  30. expect(page).to have_content "Username"
  31. end
  32. end
  33. step 'Not changed form action url' do
  34. expect(page).to have_selector %(form[action="/admin/users/#{@user.username}"])
  35. end
  36. step 'I submit modified user' do
  37. check :user_can_create_group
  38. click_button 'Save'
  39. end
  40. step 'I see user attributes changed' do
  41. expect(page).to have_content 'Can create groups: Yes'
  42. end
  43. step 'click edit on my user' do
  44. find("#edit_user_#{current_user.id}").click
  45. end
  46. step 'I view the user with secondary email' do
  47. @user_with_secondary_email = User.last
  48. @user_with_secondary_email.emails.new(email: "secondary@example.com")
  49. @user_with_secondary_email.save
  50. visit "/admin/users/#{@user_with_secondary_email.username}"
  51. end
  52. step 'I see the secondary email' do
  53. expect(page).to have_content "Secondary email: #{@user_with_secondary_email.emails.last.email}"
  54. end
  55. step 'I click remove secondary email' do
  56. find("#remove_email_#{@user_with_secondary_email.emails.last.id}").click
  57. end
  58. step 'I should not see secondary email anymore' do
  59. expect(page).not_to have_content "Secondary email:"
  60. end
  61. step 'user "Mike" with groups and projects' do
  62. user = create(:user, name: 'Mike')
  63. project = create(:empty_project)
  64. project.team << [user, :developer]
  65. group = create(:group)
  66. group.add_developer(user)
  67. end
  68. step 'click on "Mike" link' do
  69. click_link "Mike"
  70. end
  71. step 'I should see user "Mike" details' do
  72. expect(page).to have_content 'Account'
  73. expect(page).to have_content 'Personal projects limit'
  74. end
  75. step 'user "Pete" with ssh keys' do
  76. user = create(:user, name: 'Pete')
  77. create(:key, user: user, title: "ssh-rsa Key1", key: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC4FIEBXGi4bPU8kzxMefudPIJ08/gNprdNTaO9BR/ndy3+58s2HCTw2xCHcsuBmq+TsAqgEidVq4skpqoTMB+Uot5Uzp9z4764rc48dZiI661izoREoKnuRQSsRqUTHg5wrLzwxlQbl1MVfRWQpqiz/5KjBC7yLEb9AbusjnWBk8wvC1bQPQ1uLAauEA7d836tgaIsym9BrLsMVnR4P1boWD3Xp1B1T/ImJwAGHvRmP/ycIqmKdSpMdJXwxcb40efWVj0Ibbe7ii9eeoLdHACqevUZi6fwfbymdow+FeqlkPoHyGg3Cu4vD/D8+8cRc7mE/zGCWcQ15Var83Tczour Key1")
  78. create(:key, user: user, title: "ssh-rsa Key2", key: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDQSTWXhJAX/He+nG78MiRRRn7m0Pb0XbcgTxE0etArgoFoh9WtvDf36HG6tOSg/0UUNcp0dICsNAmhBKdncp6cIyPaXJTURPRAGvhI0/VDk4bi27bRnccGbJ/hDaUxZMLhhrzY0r22mjVf8PF6dvv5QUIQVm1/LeaWYsHHvLgiIjwrXirUZPnFrZw6VLREoBKG8uWvfSXw1L5eapmstqfsME8099oi+vWLR8MgEysZQmD28M73fgW4zek6LDQzKQyJx9nB+hJkKUDvcuziZjGmRFlNgSA2mguERwL1OXonD8WYUrBDGKroIvBT39zS5d9tQDnidEJZ9Y8gv5ViYP7x Key2")
  79. end
  80. step 'click on user "Pete"' do
  81. click_link 'Pete'
  82. end
  83. step 'I should see key list' do
  84. expect(page).to have_content 'ssh-rsa Key2'
  85. expect(page).to have_content 'ssh-rsa Key1'
  86. end
  87. step 'I click on the key title' do
  88. click_link 'ssh-rsa Key2'
  89. end
  90. step 'I should see key details' do
  91. expect(page).to have_content 'ssh-rsa Key2'
  92. expect(page).to have_content 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDQSTWXhJAX/He+nG78MiRRRn7m0Pb0XbcgTxE0etArgoFoh9WtvDf36HG6tOSg/0UUNcp0dICsNAmhBKdncp6cIyPaXJTURPRAGvhI0/VDk4bi27bRnccGbJ/hDaUxZMLhhrzY0r22mjVf8PF6dvv5QUIQVm1/LeaWYsHHvLgiIjwrXirUZPnFrZw6VLREoBKG8uWvfSXw1L5eapmstqfsME8099oi+vWLR8MgEysZQmD28M73fgW4zek6LDQzKQyJx9nB+hJkKUDvcuziZjGmRFlNgSA2mguERwL1OXonD8WYUrBDGKroIvBT39zS5d9tQDnidEJZ9Y8gv5ViYP7x Key2'
  93. end
  94. step 'I click on remove key' do
  95. click_link 'Remove'
  96. end
  97. step 'I should see the key removed' do
  98. expect(page).not_to have_content 'ssh-rsa Key2'
  99. end
  100. step 'user "Pete" with twitter account' do
  101. @user = create(:user, name: 'Pete')
  102. @user.identities.create!(extern_uid: '123456', provider: 'twitter')
  103. end
  104. step 'I visit "Pete" identities page in admin' do
  105. visit admin_user_identities_path(@user)
  106. end
  107. step 'I should see twitter details' do
  108. expect(page).to have_content 'Pete'
  109. expect(page).to have_content 'twitter'
  110. end
  111. step 'I modify twitter identity' do
  112. find('.table').find(:link, 'Edit').click
  113. fill_in 'identity_extern_uid', with: '654321'
  114. select 'twitter_updated', from: 'identity_provider'
  115. click_button 'Save changes'
  116. end
  117. step 'I should see twitter details updated' do
  118. expect(page).to have_content 'Pete'
  119. expect(page).to have_content 'twitter_updated'
  120. expect(page).to have_content '654321'
  121. end
  122. step 'I remove twitter identity' do
  123. click_link 'Delete'
  124. end
  125. step 'I should not see twitter details' do
  126. expect(page).to have_content 'Pete'
  127. expect(page).to_not have_content 'twitter'
  128. end
  129. step 'click on ssh keys tab' do
  130. click_link 'SSH keys'
  131. end
  132. end