Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion app/api/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@

module API
# Main base class that defines all API versions
class Base < Grape::API
class Base < Grape::API
# Normalize ActiveRecord not-found errors to a stable API message
rescue_from ActiveRecord::RecordNotFound do |e|
model = e.respond_to?(:model) && e.model ? e.model : 'Resource'
error!({ errors: ["#{model} not found"] }, 404)
end
insert_after Grape::Middleware::Formatter, Grape::Middleware::Logger, {
logger: MR.logger,
filter: Class.new do
Expand Down
5 changes: 1 addition & 4 deletions spec/api/v1/publish_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -706,10 +706,7 @@
it 'returns 404' do
transfer_ownership
expect_status(:not_found)
expect_json(
'errors.0',
"Couldn't find Organization with 'id'=#{new_organization_id}"
)
expect_json('errors.0', 'Organization not found')
end
end

Expand Down
Loading