-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove deprecated methods from AdminSet
tamsin johnson
authored and
tamsin johnson
committed
Aug 24, 2023
1 parent
eeb3c3e
commit 863c4bc
Showing
2 changed files
with
1 addition
and
116 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -112,55 +112,6 @@ | |
end | ||
end | ||
|
||
describe ".default_set?", :clean_repo do | ||
before { FactoryBot.valkyrie_create(:default_hyrax_admin_set) } | ||
context "with default AdminSet ID" do | ||
it "returns true" do | ||
expect(described_class.default_set?(described_class::DEFAULT_ID)).to be true | ||
end | ||
end | ||
|
||
context "with a non-default ID" do | ||
it "returns false" do | ||
expect(described_class.default_set?('different-id')).to be false | ||
end | ||
end | ||
end | ||
|
||
describe "#default_set?", :clean_repo do | ||
let(:default_admin_set) do | ||
administrative_set = FactoryBot.valkyrie_create(:default_hyrax_admin_set) | ||
Wings::ActiveFedoraConverter.new(resource: administrative_set).convert | ||
end | ||
context "with default AdminSet ID" do | ||
subject { default_admin_set.default_set? } | ||
|
||
it { is_expected.to be_truthy } | ||
end | ||
|
||
context "with a non-default ID" do | ||
subject { described_class.new(id: 'why-would-you-name-the-default-chupacabra?').default_set? } | ||
|
||
it { is_expected.to be_falsey } | ||
end | ||
end | ||
|
||
describe ".find_or_create_default_admin_set_id" do | ||
subject { described_class.find_or_create_default_admin_set_id } | ||
|
||
let(:default_admin_set) { build(:default_hyrax_admin_set) } | ||
|
||
before do | ||
allow(Hyrax::AdminSetCreateService).to receive(:find_or_create_default_admin_set) | ||
.and_return(default_admin_set) | ||
end | ||
|
||
it 'gets the default admin set from the create service and returns the DEFAULT_ID' do | ||
expect(Hyrax::AdminSetCreateService).to receive(:find_or_create_default_admin_set) | ||
expect(subject).to eq(described_class::DEFAULT_ID) | ||
end | ||
end | ||
|
||
describe "#destroy" do | ||
context "with member works" do | ||
before do | ||
|
@@ -227,40 +178,4 @@ | |
end | ||
end | ||
end | ||
|
||
describe '#reset_access_controls!' do | ||
let!(:user) { build(:user) } | ||
let!(:admin_set) { create(:admin_set, creator: [user.user_key], edit_users: [user.user_key], edit_groups: [::Ability.admin_group_name], read_users: [], read_groups: ['public']) } | ||
let!(:permission_template) { build(:permission_template) } | ||
|
||
before do | ||
allow(admin_set).to receive(:permission_template).and_return(permission_template) | ||
allow(permission_template).to receive(:agent_ids_for).with(access: 'manage', agent_type: 'user').and_return(['[email protected]', '[email protected]', user.user_key]) | ||
allow(permission_template).to receive(:agent_ids_for).with(access: 'manage', agent_type: 'group').and_return(['managers', ::Ability.admin_group_name]) | ||
allow(permission_template).to receive(:agent_ids_for).with(access: 'deposit', agent_type: 'user').and_return(['[email protected]', '[email protected]']) | ||
allow(permission_template).to receive(:agent_ids_for).with(access: 'deposit', agent_type: 'group').and_return(['depositors', 'registered']) | ||
allow(permission_template).to receive(:agent_ids_for).with(access: 'view', agent_type: 'user').and_return(['[email protected]', '[email protected]']) | ||
allow(permission_template).to receive(:agent_ids_for).with(access: 'view', agent_type: 'group').and_return(['viewers', 'public']) | ||
end | ||
|
||
it 'resets user edit access' do | ||
admin_set.reset_access_controls! | ||
expect(admin_set.edit_users).to match_array([user.user_key, '[email protected]', '[email protected]']) | ||
end | ||
|
||
it 'resets group edit access' do | ||
admin_set.reset_access_controls! | ||
expect(admin_set.edit_groups).to match_array(['managers', ::Ability.admin_group_name]) | ||
end | ||
|
||
it 'resets user read access' do | ||
admin_set.reset_access_controls! | ||
expect(admin_set.read_users).to match_array(['[email protected]', '[email protected]', '[email protected]', '[email protected]']) | ||
end | ||
|
||
it 'resets group read access' do | ||
admin_set.reset_access_controls! | ||
expect(admin_set.read_groups).to match_array(['depositors', 'viewers']) | ||
end | ||
end | ||
end |