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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ This method requires a resource as a parameter, and you can pass some options if
The above example will render the **User** object.

user = User.first
respond_with user, on_error: {
respond_with user, on_error: {
: :unauthorized, detail: 'Invalid user or password' }

The above example will render an **Error** response if an error would occur.
Expand Down Expand Up @@ -120,7 +120,7 @@ en:
forbidden:
title: Unauthorized
detail: User is not authorized to use this resource
unprocessable_entity:
unprocessable_content:
title: Unprocessable Entity
details: Cannot process request
conflict:
Expand Down
2 changes: 1 addition & 1 deletion lib/json_api_responders.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def record_not_found!(reason)
end

def parameter_missing!(reason)
respond_with_error(:unprocessable_entity, reason.message)
respond_with_error(:unprocessable_content, reason.message)
end

def json_api_parse_options
Expand Down
4 changes: 2 additions & 2 deletions lib/json_api_responders/responder/actions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def respond_to_show_action

def respond_to_create_action
if has_errors?
self.status ||= :unprocessable_entity
self.status ||= :unprocessable_content
render_error
else
self.status ||= :created
Expand All @@ -25,7 +25,7 @@ def respond_to_create_action

def respond_to_update_action
if has_errors?
self.status ||= :unprocessable_entity
self.status ||= :unprocessable_content
render_error
else
self.status ||= :ok
Expand Down
18 changes: 9 additions & 9 deletions spec/lib/json_api_responders/responder/actions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
json: {
errors: [
{
title: 'json_api.errors.unprocessable_entity.title',
title: 'json_api.errors.unprocessable_content.title',
detail: "Name can't be blank",
source: { parameter: :name, pointer: 'data/attributes/name' }
}
Expand Down Expand Up @@ -60,9 +60,9 @@
end

context 'when resource invalid' do
let(:status) { :unprocessable_entity }
let(:status) { :unprocessable_content }

it 'renders unprocessable_entity' do
it 'renders unprocessable_content' do
expect(controller).to receive(:render).with(error_options)
responder.respond!
end
Expand All @@ -83,9 +83,9 @@
end

context 'when resource invalid' do
let(:status) { :unprocessable_entity }
let(:status) { :unprocessable_content }

it 'renders unprocessable_entity' do
it 'renders unprocessable_content' do
expect(controller).to receive(:render).with(error_options)
responder.respond!
end
Expand Down Expand Up @@ -149,9 +149,9 @@
end

context 'when resource invalid' do
let(:status) { :unprocessable_entity }
let(:status) { :unprocessable_content }

it 'renders unprocessable_entity' do
it 'renders unprocessable_content' do
expect(controller).to receive(:render).with(error_options)
responder.respond!
end
Expand All @@ -172,9 +172,9 @@
end

context 'when resource invalid' do
let(:status) { :unprocessable_entity }
let(:status) { :unprocessable_content }

it 'renders unprocessable_entity' do
it 'renders unprocessable_content' do
expect(controller).to receive(:render).with(error_options)
responder.respond!
end
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/json_api_responders_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
content_type: 'application/vnd.api+json',
json: { errors: [
{ detail: 'Unauthorized' },
{ title: 'json_api.errors.unprocessable_entity.title',
{ title: 'json_api.errors.unprocessable_content.title',
detail: "Name can't be blank",
source: { parameter: :name, pointer: 'data/attributes/name' } }
] }
Expand Down
Loading