debian-mirror-gitlab/features/steps/admin/users.rb

168 lines
5.5 KiB
Ruby
Raw Normal View History

2015-04-26 12:48:37 +05:30
class Spinach::Features::AdminUsers < Spinach::FeatureSteps
2014-09-02 18:07:02 +05:30
include SharedAuthentication
include SharedPaths
include SharedAdmin
2015-09-11 14:41:01 +05:30
before do
2015-09-25 12:07:36 +05:30
allow(Gitlab::OAuth::Provider).to receive(:providers).and_return([:twitter, :twitter_updated])
allow_any_instance_of(ApplicationHelper).to receive(:user_omniauth_authorize_path).and_return(root_path)
2015-09-11 14:41:01 +05:30
end
after do
2015-09-25 12:07:36 +05:30
allow(Gitlab::OAuth::Provider).to receive(:providers).and_call_original
allow_any_instance_of(ApplicationHelper).to receive(:user_omniauth_authorize_path).and_call_original
2015-09-11 14:41:01 +05:30
end
2015-04-26 12:48:37 +05:30
step 'I should see all users' do
2014-09-02 18:07:02 +05:30
User.all.each do |user|
2015-09-11 14:41:01 +05:30
expect(page).to have_content user.name
2014-09-02 18:07:02 +05:30
end
end
2015-04-26 12:48:37 +05:30
step 'Click edit' do
2014-09-02 18:07:02 +05:30
@user = User.first
find("#edit_user_#{@user.id}").click
end
2015-04-26 12:48:37 +05:30
step 'Input non ascii char in username' do
2014-09-02 18:07:02 +05:30
fill_in 'user_username', with: "\u3042\u3044"
end
2015-04-26 12:48:37 +05:30
step 'Click save' do
2014-09-02 18:07:02 +05:30
click_button("Save")
end
2015-04-26 12:48:37 +05:30
step 'See username error message' do
2015-09-11 14:41:01 +05:30
page.within "#error_explanation" do
expect(page).to have_content "Username"
2014-09-02 18:07:02 +05:30
end
end
2015-04-26 12:48:37 +05:30
step 'Not changed form action url' do
2015-09-11 14:41:01 +05:30
expect(page).to have_selector %(form[action="/admin/users/#{@user.username}"])
2014-09-02 18:07:02 +05:30
end
step 'I submit modified user' do
check :user_can_create_group
click_button 'Save'
end
step 'I see user attributes changed' do
2015-09-11 14:41:01 +05:30
expect(page).to have_content 'Can create groups: Yes'
2014-09-02 18:07:02 +05:30
end
step 'click edit on my user' do
find("#edit_user_#{current_user.id}").click
end
step 'I view the user with secondary email' do
@user_with_secondary_email = User.last
@user_with_secondary_email.emails.new(email: "secondary@example.com")
@user_with_secondary_email.save
visit "/admin/users/#{@user_with_secondary_email.username}"
end
step 'I see the secondary email' do
2015-09-11 14:41:01 +05:30
expect(page).to have_content "Secondary email: #{@user_with_secondary_email.emails.last.email}"
2014-09-02 18:07:02 +05:30
end
step 'I click remove secondary email' do
find("#remove_email_#{@user_with_secondary_email.emails.last.id}").click
end
step 'I should not see secondary email anymore' do
2015-09-11 14:41:01 +05:30
expect(page).not_to have_content "Secondary email:"
2014-09-02 18:07:02 +05:30
end
2015-04-26 12:48:37 +05:30
step 'user "Mike" with groups and projects' do
user = create(:user, name: 'Mike')
project = create(:empty_project)
project.team << [user, :developer]
group = create(:group)
2015-09-11 14:41:01 +05:30
group.add_developer(user)
2015-04-26 12:48:37 +05:30
end
step 'click on "Mike" link' do
click_link "Mike"
end
step 'I should see user "Mike" details' do
2015-09-11 14:41:01 +05:30
expect(page).to have_content 'Account'
expect(page).to have_content 'Personal projects limit'
2015-04-26 12:48:37 +05:30
end
step 'user "Pete" with ssh keys' do
user = create(:user, name: 'Pete')
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")
create(:key, user: user, title: "ssh-rsa Key2", key: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDQSTWXhJAX/He+nG78MiRRRn7m0Pb0XbcgTxE0etArgoFoh9WtvDf36HG6tOSg/0UUNcp0dICsNAmhBKdncp6cIyPaXJTURPRAGvhI0/VDk4bi27bRnccGbJ/hDaUxZMLhhrzY0r22mjVf8PF6dvv5QUIQVm1/LeaWYsHHvLgiIjwrXirUZPnFrZw6VLREoBKG8uWvfSXw1L5eapmstqfsME8099oi+vWLR8MgEysZQmD28M73fgW4zek6LDQzKQyJx9nB+hJkKUDvcuziZjGmRFlNgSA2mguERwL1OXonD8WYUrBDGKroIvBT39zS5d9tQDnidEJZ9Y8gv5ViYP7x Key2")
end
step 'click on user "Pete"' do
click_link 'Pete'
end
step 'I should see key list' do
2015-09-11 14:41:01 +05:30
expect(page).to have_content 'ssh-rsa Key2'
expect(page).to have_content 'ssh-rsa Key1'
2015-04-26 12:48:37 +05:30
end
step 'I click on the key title' do
click_link 'ssh-rsa Key2'
end
step 'I should see key details' do
2015-09-11 14:41:01 +05:30
expect(page).to have_content 'ssh-rsa Key2'
expect(page).to have_content 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDQSTWXhJAX/He+nG78MiRRRn7m0Pb0XbcgTxE0etArgoFoh9WtvDf36HG6tOSg/0UUNcp0dICsNAmhBKdncp6cIyPaXJTURPRAGvhI0/VDk4bi27bRnccGbJ/hDaUxZMLhhrzY0r22mjVf8PF6dvv5QUIQVm1/LeaWYsHHvLgiIjwrXirUZPnFrZw6VLREoBKG8uWvfSXw1L5eapmstqfsME8099oi+vWLR8MgEysZQmD28M73fgW4zek6LDQzKQyJx9nB+hJkKUDvcuziZjGmRFlNgSA2mguERwL1OXonD8WYUrBDGKroIvBT39zS5d9tQDnidEJZ9Y8gv5ViYP7x Key2'
2015-04-26 12:48:37 +05:30
end
step 'I click on remove key' do
click_link 'Remove'
end
step 'I should see the key removed' do
2015-09-11 14:41:01 +05:30
expect(page).not_to have_content 'ssh-rsa Key2'
end
step 'user "Pete" with twitter account' do
@user = create(:user, name: 'Pete')
@user.identities.create!(extern_uid: '123456', provider: 'twitter')
end
step 'I visit "Pete" identities page in admin' do
visit admin_user_identities_path(@user)
end
step 'I should see twitter details' do
expect(page).to have_content 'Pete'
expect(page).to have_content 'twitter'
end
step 'I modify twitter identity' do
find('.table').find(:link, 'Edit').click
fill_in 'identity_extern_uid', with: '654321'
select 'twitter_updated', from: 'identity_provider'
click_button 'Save changes'
end
step 'I should see twitter details updated' do
expect(page).to have_content 'Pete'
expect(page).to have_content 'twitter_updated'
expect(page).to have_content '654321'
end
step 'I remove twitter identity' do
click_link 'Delete'
end
step 'I should not see twitter details' do
expect(page).to have_content 'Pete'
expect(page).not_to have_content 'twitter'
2015-09-11 14:41:01 +05:30
end
step 'click on ssh keys tab' do
click_link 'SSH keys'
2015-04-26 12:48:37 +05:30
end
2014-09-02 18:07:02 +05:30
end