-
Notifications
You must be signed in to change notification settings - Fork 64
Add support for ActiveModel::Errors. #22
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
Conversation
| end | ||
|
|
||
| class ErrorRenderer | ||
| class ErrorsRenderer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing top-level class documentation comment.
lib/jsonapi/rails/renderer.rb
Outdated
| @@ -1,3 +1,4 @@ | |||
| require 'jsonapi/rails/active_model_errors' | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing frozen string literal comment.
| end | ||
| end | ||
|
|
||
| class ActiveModelErrors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing top-level class documentation comment.
| @@ -0,0 +1,39 @@ | |||
| module JSONAPI | |||
| module Rails | |||
| class ActiveModelError | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing top-level class documentation comment.
| @@ -0,0 +1,39 @@ | |||
| module JSONAPI | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing frozen string literal comment.
498c2b5 to
85b8249
Compare
lib/jsonapi/rails/renderer.rb
Outdated
| @@ -1,3 +1,4 @@ | |||
| require 'jsonapi/rails/active_model_errors' | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing magic comment # frozen_string_literal: true.
| @@ -0,0 +1,39 @@ | |||
| module JSONAPI | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing magic comment # frozen_string_literal: true.
lib/jsonapi/rails/railtie.rb
Outdated
| end | ||
|
|
||
| ::ActionController::Renderers.add(:jsonapi_error) do |errors, options| | ||
| ::ActionController::Renderers.add(:jsonapi_errors) do |errors, options| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long. [81/80]
f49e9a7 to
57afcdd
Compare
57afcdd to
ac98273
Compare
spec/render_jsonapi_spec.rb
Outdated
| @@ -0,0 +1,62 @@ | |||
| require 'rails_helper' | |||
|
|
|||
| describe ActionController::Base, "#render", type: :controller do | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Block has too many lines. [49/25]
Prefer single-quoted strings when you don't need string interpolation or special symbols.
spec/render_jsonapi_errors_spec.rb
Outdated
| { | ||
| detail: 'Email must be a valid email', | ||
| title: 'Invalid email', | ||
| source: { pointer: "/data/attributes/email" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer single-quoted strings when you don't need string interpolation or special symbols.
spec/render_jsonapi_errors_spec.rb
Outdated
| { | ||
| detail: 'Name can\'t be blank', | ||
| title: 'Invalid name', | ||
| source: { pointer: "/data/attributes/name" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer single-quoted strings when you don't need string interpolation or special symbols.
|
|
||
| context 'when rendering error hashes' do | ||
| controller do | ||
| def create |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Method has too many lines. [13/10]
spec/render_jsonapi_errors_spec.rb
Outdated
| end | ||
| end | ||
|
|
||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra blank line detected.
spec/render_jsonapi_errors_spec.rb
Outdated
| }, | ||
| { | ||
| "detail" => "Email must be a valid email", | ||
| "title" => "Invalid email", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer single-quoted strings when you don't need string interpolation or special symbols.
spec/render_jsonapi_errors_spec.rb
Outdated
| "source" => { "pointer"=>"/data/attributes/name" } | ||
| }, | ||
| { | ||
| "detail" => "Email must be a valid email", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer single-quoted strings when you don't need string interpolation or special symbols.
spec/render_jsonapi_errors_spec.rb
Outdated
| "detail" => "Name can't be blank", | ||
| "title" => "Invalid name", | ||
| "source" => { "pointer"=>"/data/attributes/name" } | ||
| }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indent the right brace the same as the start of the line where the left brace is.
spec/render_jsonapi_errors_spec.rb
Outdated
| "errors" => [{ | ||
| "detail" => "Name can't be blank", | ||
| "title" => "Invalid name", | ||
| "source" => { "pointer"=>"/data/attributes/name" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer single-quoted strings when you don't need string interpolation or special symbols.
Surrounding space missing for operator =>.
spec/render_jsonapi_errors_spec.rb
Outdated
| { | ||
| "errors" => [{ | ||
| "detail" => "Name can't be blank", | ||
| "title" => "Invalid name", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer single-quoted strings when you don't need string interpolation or special symbols.
7078321 to
e496357
Compare
spec/render_jsonapi_errors_spec.rb
Outdated
| let(:serialized_errors) do | ||
| { | ||
| 'errors' => [{ | ||
| 'detail' => 'Name can\'t be blank', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use 2 spaces for indentation in a hash, relative to the start of the line where the left curly brace is.
276e7dc to
a7e6841
Compare
| end | ||
| end | ||
|
|
||
| class ActiveModelErrors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing top-level class documentation comment.
0811702 to
0e13ab6
Compare
lib/jsonapi/rails/renderer.rb
Outdated
| options[:expose] = | ||
| controller.jsonapi_expose | ||
| .merge!(options[:expose] || {}) | ||
| .merge!(_jsonapi_pointers: controller.jsonapi_pointers) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Align .merge! with .jsonapi_expose on line 70.
lib/jsonapi/rails/renderer.rb
Outdated
| options.dup.tap do |options| | ||
| options[:expose] = | ||
| controller.jsonapi_expose | ||
| .merge!(options[:expose] || {}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Align .merge! with .jsonapi_expose on line 70.
lib/jsonapi/rails/renderer.rb
Outdated
|
|
||
| # @api private | ||
| def default_options(options, controller) | ||
| options.dup.tap do |options| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shadowing outer local variable - options.
lib/jsonapi/rails/renderer.rb
Outdated
| (options[:links] ||= {}).merge!(pagination_links) | ||
| end | ||
| options[:expose] = controller.jsonapi_expose | ||
| .merge!(options[:expose] || {}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Align .merge! with .jsonapi_expose on line 27.
lib/jsonapi/rails/renderer.rb
Outdated
|
|
||
| # @api private | ||
| def default_options(options, controller, resources) | ||
| options.dup.tap do |options| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shadowing outer local variable - options.
0e13ab6 to
d012897
Compare
49ce233 to
cfcf79a
Compare
cfcf79a to
3fe4bad
Compare
3fe4bad to
9caf4a0
Compare
65a3db7 to
f98b88b
Compare
f98b88b to
99a0509
Compare
5d22a0b to
86fde0c
Compare
No description provided.