Skip to content

Commit

Permalink
Allow to remove suspended role (forem#20439)
Browse files Browse the repository at this point in the history
* Allow to remove suspended role

* Fixed the cypress spec for removing suspended role
  • Loading branch information
lightalloy authored Dec 12, 2023
1 parent 9eaa196 commit e0ba90d
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
2 changes: 0 additions & 2 deletions app/policies/role_policy.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
class RolePolicy < ApplicationPolicy
def remove_role?
return false if record.suspended?

if user.super_admin?
true
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ describe('Manage User Roles', () => {
verifyAndDismissFlashMessage('User has been updated', 'flash-success');

cy.findByRole('button', {
name: "Suspended You can't remove this role.",
name: 'Remove role: Suspended',
}).should('exist');
checkUserStatus('Suspended');

Expand Down
4 changes: 2 additions & 2 deletions spec/policies/role_policy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
let(:admin_user) { build(:user, :admin) }

permissions :remove_role? do
it "denies access if current role is suspended" do
expect(role).not_to permit(super_admin_user, role_suspended)
it "allows access for super_admin if the role is suspended" do
expect(role).to permit(super_admin_user, role_suspended)
end

it "grants access if user is super admin" do
Expand Down

0 comments on commit e0ba90d

Please sign in to comment.