Skip to content

Commit

Permalink
Merge pull request #6279 from samvera/vis-prop-spec
Browse files Browse the repository at this point in the history
make ResourceVisibilityPropagator use Valkyrie for setup
  • Loading branch information
tpendragon authored Aug 31, 2023
2 parents 233c29a + b1b1bea commit a811e7b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
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

0 comments on commit a811e7b

Please sign in to comment.