Skip to content

Commit

Permalink
Convert Ldp::Gone to ObjectNotFoundError
Browse files Browse the repository at this point in the history
Ldp::Gone is the error raised by the fedora adapter when the resource is a tombstone after being deleted.
  • Loading branch information
dlpierce committed Oct 25, 2024
1 parent c42c31c commit 868af43
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/services/hyrax/custom_queries/find_access_control.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def find_access_control_for(resource:)
.find_inverse_references_by(resource: resource, property: :access_to)
.find { |r| r.is_a?(Hyrax::AccessControl) } ||
raise(Valkyrie::Persistence::ObjectNotFoundError)
rescue ArgumentError # some adapters raise ArgumentError for missing resources
rescue ArgumentError, Ldp::Gone # some adapters raise ArgumentError for missing resources
raise(Valkyrie::Persistence::ObjectNotFoundError)
end
end
Expand Down
11 changes: 11 additions & 0 deletions spec/services/hyrax/custom_queries/find_access_control_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@
end
end

context 'for deleted object' do
let(:resource) { persister.save(resource: Hyrax::Resource.new) }

before { persister.delete(resource: resource) }

it 'raises ObjectNotFoundError' do
expect { query_handler.find_access_control_for(resource: resource) }
.to raise_error Valkyrie::Persistence::ObjectNotFoundError
end
end

context 'when an acl exists' do
let(:acl) { persister.save(resource: Hyrax::AccessControl.new(access_to: resource.id)) }
let(:resource) { persister.save(resource: Hyrax::Resource.new) }
Expand Down

0 comments on commit 868af43

Please sign in to comment.