Skip to content

Commit

Permalink
Merge 1f486a6 into f32359e
Browse files Browse the repository at this point in the history
  • Loading branch information
ndushay committed Sep 6, 2019
2 parents f32359e + 1f486a6 commit c16f3c8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/controllers/objects_controller.rb
Expand Up @@ -3,6 +3,10 @@
class ObjectsController < ApplicationController
before_action :load_item, except: [:create]

rescue_from(ActiveFedora::ObjectNotFoundError) do |e|
render status: :not_found, plain: e.message
end

rescue_from(Dor::ParameterError) do |e|
render status: :bad_request, plain: e.message
end
Expand Down
7 changes: 7 additions & 0 deletions spec/controllers/objects_controller_spec.rb
Expand Up @@ -48,6 +48,13 @@
expect(response.status).to eq(500)
expect(response.body).to eq(errmsg)
end

it 'returns a 404 error for ActiveFedora::ObjectNotFoundError' do
allow(RegistrationService).to receive(:register_object).and_raise(ActiveFedora::ObjectNotFoundError.new(errmsg))
post :create
expect(response.status).to eq(404)
expect(response.body).to eq(errmsg)
end
end

it 'registers the object with the registration service' do
Expand Down

0 comments on commit c16f3c8

Please sign in to comment.