Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make ResourceVisibilityPropagator use Valkyrie for setup #6279

Merged
merged 1 commit into from
Aug 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions spec/factories/hyrax_work.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@
work.permission_manager.edit_users = evaluator.edit_users
work.permission_manager.read_users = evaluator.read_users

# these are both no-ops if an active embargo/lease isn't present
Hyrax::EmbargoManager.new(resource: work).apply
Hyrax::LeaseManager.new(resource: work).apply

work.permission_manager.acl.save

Hyrax.index_adapter.save(resource: work) if evaluator.with_index
Expand Down
12 changes: 6 additions & 6 deletions spec/services/hyrax/resource_visibility_propagator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
RSpec.describe Hyrax::ResourceVisibilityPropagator do
subject(:propagator) { described_class.new(source: work) }
let(:queries) { Hyrax.custom_queries }
let(:work) { FactoryBot.create(:work_with_files).valkyrie_resource }
let(:work) { FactoryBot.valkyrie_create(:hyrax_work, :with_member_file_sets) }
let(:file_sets) { queries.find_child_file_sets(resource: work) }

context 'a public work' do
Expand All @@ -14,13 +14,13 @@
expect(file_sets.first.visibility).to eq 'restricted'

expect { propagator.propagate }
.to change { queries.find_child_file_sets(resource: work).map(&:visibility) }
.to change { queries.find_child_file_sets(resource: work).map(&:visibility).to_a }
.to contain_exactly(work.visibility, work.visibility)
end
end

context 'when work is under embargo' do
let(:work) { FactoryBot.create(:embargoed_work_with_files).valkyrie_resource }
let(:work) { FactoryBot.valkyrie_create(:hyrax_work, :under_embargo, :with_member_file_sets) }

before do
fs = file_sets.first
Expand All @@ -30,7 +30,7 @@

it 'copies visibility' do
expect { propagator.propagate }
.to change { queries.find_child_file_sets(resource: work).map(&:visibility) }
.to change { queries.find_child_file_sets(resource: work).map(&:visibility).to_a }
.to contain_exactly(work.visibility, work.visibility)
end

Expand All @@ -45,7 +45,7 @@
end

context 'when work is under lease' do
let(:work) { FactoryBot.create(:leased_work_with_files).valkyrie_resource }
let(:work) { FactoryBot.valkyrie_create(:hyrax_work, :under_lease, :with_member_file_sets) }

before do
fs = file_sets.first
Expand All @@ -55,7 +55,7 @@

it 'copies visibility' do
expect { propagator.propagate }
.to change { queries.find_child_file_sets(resource: work).map(&:visibility) }
.to change { queries.find_child_file_sets(resource: work).map(&:visibility).to_a }
.to contain_exactly(work.visibility, work.visibility)
end

Expand Down