Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Grant edit access to managers of AdminSet
Fixes samvera/hyku#417
- Loading branch information
Showing
6 changed files
with
110 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
require 'spec_helper' | ||
|
||
RSpec.describe Sufia::Forms::PermissionTemplateForm do | ||
describe "#update" do | ||
let(:input_params) do | ||
ActionController::Parameters.new(access_grants_attributes: grant_attributes).permit! | ||
end | ||
let(:admin_set) { create(:admin_set) } | ||
let(:permission_template) { create(:permission_template, admin_set_id: admin_set.id) } | ||
let(:form) { described_class.new(permission_template) } | ||
subject { form.update(input_params) } | ||
|
||
context "with a user manager" do | ||
let(:grant_attributes) do | ||
[ActionController::Parameters.new(agent_type: "user", | ||
agent_id: "bob", | ||
access: "manage").permit!] | ||
end | ||
it "also adds edit_access to the AdminSet itself" do | ||
expect { subject }.to change { permission_template.access_grants.count }.by(1) | ||
expect(admin_set.reload.edit_users).to include 'bob' | ||
end | ||
end | ||
|
||
context "with a group manager" do | ||
let(:grant_attributes) do | ||
[ActionController::Parameters.new(agent_type: "group", | ||
agent_id: "bob", | ||
access: "manage").permit!] | ||
end | ||
it "also adds edit_access to the AdminSet itself" do | ||
expect { subject }.to change { permission_template.access_grants.count }.by(1) | ||
expect(admin_set.reload.edit_groups).to include 'bob' | ||
end | ||
end | ||
|
||
context "without a manager" do | ||
let(:grant_attributes) do | ||
[ActionController::Parameters.new(agent_type: "user", | ||
agent_id: "bob", | ||
access: "view").permit!] | ||
end | ||
it "doesn't adds edit_access to the AdminSet itself" do | ||
expect { subject }.to change { permission_template.access_grants.count }.by(1) | ||
expect(admin_set.reload.edit_users).to be_empty | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters