Skip to content
Merged
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
2 changes: 1 addition & 1 deletion jsonapi.rb.gemspec

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, I also had to increase the sqlite3 version.

Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Gem::Specification.new do |spec|
spec.add_development_dependency 'ransack'
spec.add_development_dependency 'railties', ENV['RAILS_VERSION']
spec.add_development_dependency 'activerecord', ENV['RAILS_VERSION']
spec.add_development_dependency 'sqlite3', '~> 1.7'
spec.add_development_dependency 'sqlite3', '~> 2.1'
spec.add_development_dependency 'ffaker'
spec.add_development_dependency 'rspec', '~> 3.0'
spec.add_development_dependency 'rspec-rails'
Expand Down
2 changes: 1 addition & 1 deletion lib/jsonapi/errors.rb

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was getting several instances of the warning: Status code :unprocessable_entity is deprecated and will be removed in a future version of Rack. Please use :unprocessable_content instead.

This change removes said warning.

Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def render_jsonapi_not_found(exception)
render jsonapi_errors: [error], status: :not_found
end

# Unprocessable entity (422) error handler callback
# Unprocessable Content (422) error handler callback
#
# @param exception [Exception] instance to handle
# @return [String] JSONAPI error response
Expand Down
2 changes: 1 addition & 1 deletion lib/jsonapi/pagination.rb
Copy link

@SamuelB-MT SamuelB-MT Dec 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, as seen in the screenshot request.fullpath is un-escaped, adding CGI.unescape resolves this gap:
image
I added puts debug statements to print the link without CGI.unescape (current code) and with CGI.unescape (proposed change).

Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def jsonapi_paginate(resources)
#
# @return [Array]
def jsonapi_pagination(resources)
links = { self: request.base_url + request.fullpath }
links = { self: request.base_url + CGI.unescape(request.fullpath) }
pagination = jsonapi_pagination_meta(resources)

return links if pagination.blank?
Expand Down
1 change: 0 additions & 1 deletion spec/dummy.rb
Copy link

@SamuelB-MT SamuelB-MT Dec 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, I had to remove this line too to get the command rake spec to work without errors.
I also suggest an additional change:
image

Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ class UserSerializer
end

class Dummy < Rails::Application
secrets.secret_key_base = '_'
config.hosts << 'www.example.com' if config.respond_to?(:hosts)

routes.draw do
Expand Down
14 changes: 7 additions & 7 deletions spec/errors_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
{
'status' => '422',
'source' => { 'pointer' => '' },
'title' => 'Unprocessable Entity',
'title' => 'Unprocessable Content',
'detail' => nil,
'code' => nil
}
Expand All @@ -63,7 +63,7 @@
{
'status' => '422',
'source' => { 'pointer' => '/data/relationships/user' },
'title' => 'Unprocessable Entity',
'title' => 'Unprocessable Content',
'detail' => expected_detail,
'code' => 'blank'
}
Expand All @@ -85,21 +85,21 @@
{
'status' => '422',
'source' => { 'pointer' => '/data/attributes/title' },
'title' => 'Unprocessable Entity',
'title' => 'Unprocessable Content',
'detail' => 'Title is invalid',
'code' => 'invalid'
},
{
'status' => '422',
'source' => { 'pointer' => '/data/attributes/title' },
'title' => 'Unprocessable Entity',
'title' => 'Unprocessable Content',
'detail' => 'Title has typos',
'code' => 'invalid'
},
{
'status' => '422',
'source' => { 'pointer' => '/data/attributes/quantity' },
'title' => 'Unprocessable Entity',
'title' => 'Unprocessable Content',
'detail' => 'Quantity must be less than 100',
'code' => 'less_than'
}
Expand All @@ -121,7 +121,7 @@
{
'status' => '422',
'source' => { 'pointer' => '' },
'title' => 'Unprocessable Entity',
'title' => 'Unprocessable Content',
'detail' => 'Title has slurs',
'code' => 'title_has_slurs'
}
Expand All @@ -144,7 +144,7 @@
{
'status' => '422',
'source' => { 'pointer' => '/data/attributes/title' },
'title' => 'Unprocessable Entity',
'title' => 'Unprocessable Content',
'detail' => nil,
'code' => nil
}
Expand Down