add cancan for authorization
This commit is contained in:
@@ -23,6 +23,7 @@ RSpec.describe 'Dashboard Page' do
|
||||
context 'when there are templates' do
|
||||
let!(:authors) { create_list(:user, 5, account:) }
|
||||
let!(:templates) { authors.map { |author| create(:template, account:, author:) } }
|
||||
let!(:other_template) { create(:template) }
|
||||
|
||||
before do
|
||||
visit root_path
|
||||
@@ -35,6 +36,7 @@ RSpec.describe 'Dashboard Page' do
|
||||
end
|
||||
|
||||
expect(page).to have_content('Templates')
|
||||
expect(page).not_to have_content(other_template.name)
|
||||
expect(page).to have_link('Create', href: new_template_path)
|
||||
end
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ RSpec.describe 'Team Settings' do
|
||||
|
||||
context 'when multiple users' do
|
||||
let!(:users) { create_list(:user, 2, account:) }
|
||||
let!(:other_user) { create(:user) }
|
||||
|
||||
before do
|
||||
visit settings_users_path
|
||||
@@ -22,6 +23,7 @@ RSpec.describe 'Team Settings' do
|
||||
users.each do |user|
|
||||
expect(page).to have_content(user.full_name)
|
||||
expect(page).to have_content(user.email)
|
||||
expect(page).not_to have_content(other_user.email)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -84,13 +86,7 @@ RSpec.describe 'Team Settings' do
|
||||
end
|
||||
|
||||
it 'does not allow to remove the current user' do
|
||||
expect do
|
||||
accept_confirm('Are you sure?') do
|
||||
first(:button, 'Delete').click
|
||||
end
|
||||
end.not_to(change { User.admins.count })
|
||||
|
||||
expect(page).to have_content('Unable to remove user')
|
||||
expect(page).not_to have_content('User has been removed')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user