Implement role authorization
This commit is contained in:
parent
6755328c4c
commit
e2fb434dc7
122 changed files with 1386 additions and 751 deletions
|
|
@ -1,14 +1,10 @@
|
|||
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
|
||||
scenario 'deletes a user', feature: true, js: true do
|
||||
sign_in(admin)
|
||||
sign_in(create(:admin))
|
||||
visit admin_users_path
|
||||
expected_count = User.count - 1
|
||||
page.all('btn btn-primary btn-danger') do
|
||||
|
|
@ -20,20 +16,6 @@ feature User do
|
|||
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
|
||||
if 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
|
||||
end
|
||||
sign_out
|
||||
end
|
||||
end
|
||||
|
||||
describe 'admin' do
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue