Skip to content

Commit 7589582

Browse files
Allow the removal of permission sets
The assign_permissions method in solidus_core is only calling concat on the permission set, which is fine for adding new permission sets. In a case on a removal the permission set would persist until the server is restarted.
1 parent aaab6f6 commit 7589582

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

app/decorators/models/solidus_user_roles/spree/role_decorator.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def permission_sets_constantized
1717
end
1818

1919
def assign_permissions
20-
::Spree::Config.roles.assign_permissions name, permission_sets_constantized
20+
::Spree::Config.roles.roles[name] = ::Spree::RoleConfiguration::Role.new(name, permission_sets_constantized)
2121
end
2222

2323
::Spree::Role.prepend self

spec/models/spree/role_spec.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@
2222

2323
expect { role.save }.to change { Spree::Config.roles.roles[role.name].permission_sets.count }.from(1).to(2)
2424
end
25+
26+
it "removes existing permission sets" do
27+
role.save
28+
role.permission_sets = []
29+
30+
expect { role.save }.to change { Spree::Config.roles.roles[role.name].permission_sets.count }.from(1).to(0)
31+
end
2532
end
2633

2734
describe "#destroy" do

0 commit comments

Comments
 (0)