Skip to content

Commit

Permalink
Merge 1da1fd2 into 913ab5f
Browse files Browse the repository at this point in the history
  • Loading branch information
mjgiarlo committed Aug 22, 2019
2 parents 913ab5f + 1da1fd2 commit 57531d7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
4 changes: 4 additions & 0 deletions app/controllers/objects_controller.rb
Expand Up @@ -11,6 +11,10 @@ class ObjectsController < ApplicationController
render status: 409, plain: e.message, location: object_location(e.pid)
end

rescue_from(DublinCoreService::CrosswalkError) do |e|
render status: 400, plain: e.message
end

# Register new objects in DOR
def create
Rails.logger.info(params.inspect)
Expand Down
13 changes: 12 additions & 1 deletion spec/controllers/objects_controller_spec.rb
Expand Up @@ -53,11 +53,22 @@
end

describe '/publish' do
it 'calls publish metadata' do
it 'calls PublishMetadataService and returns 201' do
expect(PublishMetadataService).to receive(:publish).with(item)
post :publish, params: { id: item.pid }
expect(response.status).to eq(201)
end

context 'with bad metadata' do
let(:error_message) { "DublinCoreService#ng_xml produced incorrect xml (no children):\n<xml/>" }

it 'returns a 400 error' do
allow(PublishMetadataService).to receive(:publish).and_raise(DublinCoreService::CrosswalkError, error_message)
post :publish, params: { id: item.pid }
expect(response.status).to eq(400)
expect(response.body).to eq(error_message)
end
end
end

describe '/update_marc_record' do
Expand Down

0 comments on commit 57531d7

Please sign in to comment.