Skip to content

Updates specs to run on newer ruby versions, adds CGI.unescape to request.fullpath #108

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
@@ -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'
2 changes: 1 addition & 1 deletion lib/jsonapi/errors.rb
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion lib/jsonapi/pagination.rb
Original file line number Diff line number Diff line change
@@ -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?
1 change: 0 additions & 1 deletion spec/dummy.rb
Original file line number Diff line number Diff line change
@@ -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
14 changes: 7 additions & 7 deletions spec/errors_spec.rb
Original file line number Diff line number Diff line change
@@ -36,7 +36,7 @@
{
'status' => '422',
'source' => { 'pointer' => '' },
'title' => 'Unprocessable Entity',
'title' => 'Unprocessable Content',
'detail' => nil,
'code' => nil
}
@@ -63,7 +63,7 @@
{
'status' => '422',
'source' => { 'pointer' => '/data/relationships/user' },
'title' => 'Unprocessable Entity',
'title' => 'Unprocessable Content',
'detail' => expected_detail,
'code' => 'blank'
}
@@ -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'
}
@@ -121,7 +121,7 @@
{
'status' => '422',
'source' => { 'pointer' => '' },
'title' => 'Unprocessable Entity',
'title' => 'Unprocessable Content',
'detail' => 'Title has slurs',
'code' => 'title_has_slurs'
}
@@ -144,7 +144,7 @@
{
'status' => '422',
'source' => { 'pointer' => '/data/attributes/title' },
'title' => 'Unprocessable Entity',
'title' => 'Unprocessable Content',
'detail' => nil,
'code' => nil
}