Skip to content

Commit

Permalink
pohandler_spec: added test for confirm_version guards for missing obj…
Browse files Browse the repository at this point in the history
…ects
  • Loading branch information
ndushay committed Nov 29, 2017
1 parent d01defc commit 59a8581
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions spec/services/preserved_object_handler_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,22 @@
)
end

it 'stops processing if there is no PreservedCopy' do
druid = 'nd000lm0000'
diff_ep = Endpoint.create!(
endpoint_name: 'diff_endpoint',
endpoint_type: Endpoint.default_storage_root_endpoint_type,
endpoint_node: 'localhost',
storage_location: 'blah',
recovery_cost: 1
)
po = PreservedObject.create!(druid: druid, current_version: 2, preservation_policy: default_prez_policy)
po_handler = described_class.new(druid, 3, incoming_size, diff_ep)
results = po_handler.confirm_version
expect(results).to include(a_hash_including(PreservedObjectHandler::OBJECT_DOES_NOT_EXIST => a_string_matching("ActiveRecord::RecordNotFound: Couldn't find PreservedCopy> db object does not exist")))
expect(PreservedObject.find_by(druid: druid).current_version).to eq 2
end

context "incoming and db versions match" do
let(:po_handler) { described_class.new(druid, 2, 1, ep) }
let(:exp_msg_prefix) { "PreservedObjectHandler(#{druid}, 2, 1, #{ep})" }
Expand Down

0 comments on commit 59a8581

Please sign in to comment.