Skip to content

Commit

Permalink
Fix BufferedPersister.
Browse files Browse the repository at this point in the history
  • Loading branch information
tpendragon committed Jul 28, 2021
1 parent 8d12c44 commit 59bf5ac
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/valkyrie/persistence/delete_tracking_buffer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ def delete(resource:)
@deletes << resource
super
end

# A buffered memory persister can save anything, it doesn't have to hold
# a consistent internal state.
def valid_for_save?(_)
true
end
end
end
end
10 changes: 10 additions & 0 deletions spec/valkyrie/persistence/buffered_persister_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,15 @@ class Resource < Valkyrie::Resource
end
expect(buffer.query_service.find_all.length).to eq 1
end
it "can handle saving an object which was previously saved" do
buffer = nil
resource = Resource.new
output = adapter.persister.save(resource: resource)
persister.with_buffer do |inner_persister, memory_buffer|
inner_persister.save(resource: output)
buffer = memory_buffer
end
expect(buffer.query_service.find_all.length).to eq 1
end
end
end

0 comments on commit 59bf5ac

Please sign in to comment.