mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-16 21:24:05 +00:00
Feature testing user specs
This commit is contained in:
parent
c6f2b4f641
commit
98e3784eba
4 changed files with 164 additions and 3 deletions
39
spec/features/user_spec.rb
Normal file
39
spec/features/user_spec.rb
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
require 'spec_helper'
|
||||
feature User do
|
||||
# It is necessary to use bang version of let to build roles before user
|
||||
let!(:organizer_role) { create(:organizer_role) }
|
||||
let!(:participant_role) { create(:participant_role) }
|
||||
let!(:admin_role) { create(:admin_role) }
|
||||
let(:admin) { create(:admin) }
|
||||
shared_examples 'admin ability' do |user|
|
||||
scenario 'deletes a user', feature: true, js: true do
|
||||
sign_in(admin)
|
||||
visit admin_users_path
|
||||
expected_count = User.count - 1
|
||||
page.all('btn btn-primary btn-danger') do
|
||||
click_link 'Delete'
|
||||
page.evaluate_script('window.confirm = function() { return true; }')
|
||||
page.click('OK')
|
||||
expect(flash).to eq('User got deleted')
|
||||
expect(User.count).to eq(expected_count)
|
||||
end
|
||||
sign_out
|
||||
end
|
||||
scenario 'can modify roles', feature: true, js: true do
|
||||
@user = create(:user)
|
||||
sign_in(admin)
|
||||
visit admin_users_path
|
||||
find("#user-modify-role-#{@user.id}").click
|
||||
find("#user-role-selection-#{@user.id}").visible?
|
||||
page.find('#user_role_ids').find(:xpath, 'option[2]').select_option do
|
||||
find('#user_submit_action').click
|
||||
expect(flash).to eq("Updated #{@user.email}")
|
||||
expect(@user.role_ids).to match_array([2])
|
||||
end
|
||||
sign_out
|
||||
end
|
||||
end
|
||||
describe 'admin' do
|
||||
it_behaves_like 'admin ability', :admin
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue