Skip to content

Commit

Permalink
Add a shared persister spec for saving a deleted resource
Browse files Browse the repository at this point in the history
refs #837

Co-authored-by: Ayse Durmaz <[email protected]>
  • Loading branch information
2 people authored and tpendragon committed Jul 28, 2021
1 parent 68c2a17 commit 5e6b03c
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/valkyrie/specs/shared_specs/persister.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,18 @@ class CustomResource < Valkyrie::Resource
expect(reloaded.nested_resource.first.title).to eq ["Nested"]
end

context "when a persisted resource is not in the database" do
it "throws an ObjectNotFoundError" do
expect(resource).not_to be_persisted
saved = persister.save(resource: resource)

expect(saved).to be_persisted
persister.delete(resource: saved)

expect { persister.save(resource: saved) }.to raise_error(Valkyrie::Persistence::ObjectNotFoundError)
end
end

it "can persist single values" do
resource.single_value = "A single value"

Expand Down

0 comments on commit 5e6b03c

Please sign in to comment.