Skip to content

Commit

Permalink
Updates tested collection objects to Valkyrie-compliant (spec/search_…
Browse files Browse the repository at this point in the history
…builders/hyrax/collection_search_builder_spec.rb). (#6453)

* Utilizes Valkyrie pattern for access_grants.
  • Loading branch information
bwatson78 authored Nov 27, 2023
1 parent e863df4 commit c9b0ee5
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions spec/search_builders/hyrax/collection_search_builder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,22 +49,31 @@

context 'when access is :deposit' do
let(:access) { "deposit" }
let!(:collection) { FactoryBot.create(:collection_lw, with_permission_template: attributes) }
let(:access_grant) do
{ agent_type:,
agent_id: user.user_key,
access: Hyrax::PermissionTemplateAccess::DEPOSIT}
end
let!(:collection) do
valkyrie_create(:hyrax_collection, user: user, access_grants: [access_grant])
end

context 'and user has access' do
let(:attributes) { { deposit_users: [user.user_key] } }
let(:agent_type) { Hyrax::PermissionTemplateAccess::USER }

it { is_expected.to eq ["{!terms f=id}#{collection.id}"] }
end

context 'and group has access' do
let(:attributes) { { deposit_groups: ['registered'] } }
let(:agent_type) { Hyrax::PermissionTemplateAccess::GROUP }

it { is_expected.to eq ["{!terms f=id}#{collection.id}"] }
end

context "and user has no access" do
let(:attributes) { true }
let(:collection) do
valkyrie_create(:hyrax_collection, :with_permission_template)
end

it { is_expected.to eq ["{!terms f=id}"] }
end
Expand Down

0 comments on commit c9b0ee5

Please sign in to comment.