Commit b492551d authored by Tugce Nur Tas's avatar Tugce Nur Tas Committed by Tuğçe Nur Taş
Browse files

adapt user deletion tests

parent be4cf93f
......@@ -11,18 +11,14 @@ class UserPolicyTest < ActiveSupport::TestCase
test 'Destroy: superadmin can delete other user' do
assert_permit @user_as_superadmin, @user_as_social_worker, 'destroy?'
assert_permit @user_as_superadmin, @user_as_department_manager, 'destroy?'
assert_permit @user_as_other_superadmin, @user_as_social_worker, 'destroy?'
assert_permit @user_as_other_superadmin, @user_as_department_manager, 'destroy?'
end
test 'Destroy: superadmin cannot delete other superadmin' do
refute_permit @user_as_superadmin, @user_as_other_superadmin, 'destroy?'
refute_permit @user_as_other_superadmin, @user_as_superadmin, 'destroy?'
end
test 'Destroy: superadmin cannot delete itself' do
refute_permit @user_as_superadmin, @user_as_superadmin, 'destroy?'
refute_permit @user_as_other_superadmin, @user_as_other_superadmin, 'destroy?'
end
test 'New: superadmin can create user' do
......
......@@ -4,7 +4,7 @@ class UsersTest < ApplicationSystemTestCase
setup do
@emails = ActionMailer::Base.deliveries
@emails.clear
@user = create :user, email: 'superadmin@example.com', role: 'superadmin'
@user = create :user, email: 'superadmin@example.com'
login_as @user
visit new_user_path
end
......@@ -65,11 +65,17 @@ class UsersTest < ApplicationSystemTestCase
assert_equal 'superadmin@test.ch', email['to'].to_s
end
test "superadmins can't destroy superadmin" do
test 'superadmin can destroy social worker' do
create :user, role: 'social_worker'
visit users_path
assert page.has_link? 'Delete'
end
test "superadmin can't destroy superadmin" do
create :user, role: 'superadmin'
visit users_path
@social_worker = create :user, role: 'social_worker'
@department_manager = create :user, role: 'department_manager'
assert_not page.has_link? 'Delete'
end
end
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment