Skip to content

Commit

Permalink
pohandler: ensure we don't output results if db update fails
Browse files Browse the repository at this point in the history
  • Loading branch information
ndushay committed Nov 29, 2017
1 parent a8afa66 commit d01defc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/services/preserved_object_handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def create_db_objects(status, validated=false)
end
PreservedCopy.create!(pc_attrs)
end
results << result_hash(CREATED_NEW_OBJECT)
results << result_hash(CREATED_NEW_OBJECT) unless create_results.include?(DB_UPDATE_FAILED)
results.concat(create_results)
end

Expand Down
3 changes: 3 additions & 0 deletions spec/services/preserved_object_handler_create_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@
it "exception's message" do
expect(results).to include(a_hash_including(result_code => a_string_matching('foo')))
end
it 'does NOT get CREATED_NEW_OBJECT message' do
expect(results).to include(hash_not_including(PreservedObjectHandler::CREATED_NEW_OBJECT))
end
end
end

Expand Down
8 changes: 8 additions & 0 deletions spec/services/preserved_object_handler_update_version_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,10 @@
it "exception's message" do
expect(results).to include(a_hash_including(result_code => a_string_matching('foo')))
end
it 'does NOT get UPDATED_DB_OBJECT message' do
expect(results).to include(hash_not_including(PreservedObjectHandler::UPDATED_DB_OBJECT))
expect(results).to include(hash_not_including(PreservedObjectHandler::UPDATED_DB_OBJECT_TIMESTAMP_ONLY))
end
end
end
end
Expand Down Expand Up @@ -282,6 +286,10 @@
it "exception's message" do
expect(results).to include(a_hash_including(result_code => a_string_matching('foo')))
end
it 'does NOT get UPDATED_DB_OBJECT message' do
expect(results).to include(hash_not_including(PreservedObjectHandler::UPDATED_DB_OBJECT))
expect(results).to include(hash_not_including(PreservedObjectHandler::UPDATED_DB_OBJECT_TIMESTAMP_ONLY))
end
end
end
end
Expand Down

0 comments on commit d01defc

Please sign in to comment.