Open sosolidkk opened 1 month ago
I didn't address on this PR, but there's seems to be a error being improperly raised on this spec.
with an exception
E, [2024-08-14T11:13:38.439786 #77087] ERROR -- : undefined method `raise_error!' for an instance of NotesController (NoMethodError)
/home/jpechaves/Github/jsonapi.rb/spec/dummy.rb:148:in `update'
/home/jpechaves/.asdf/installs/ruby/3.3.4/lib/ruby/gems/3.3.0/gems/actionpack-7.2.0/lib/action_controller/metal/basic_implicit_render.rb:8:in `send_action'
/home/jpechaves/.asdf/installs/ruby/3.3.4/lib/ruby/gems/3.3.0/gems/actionpack-7.2.0/lib/abstract_controller/base.rb:226:in `process_action'
/home/jpechaves/.asdf/installs/ruby/3.3.4/lib/ruby/gems/3.3.0/gems/actionpack-7.2.0/lib/action_controller/metal/rendering.rb:193:in `process_action'
# ...
is expected to contain exactly {"code"=>nil, "detail"=>nil, "links"=>nil, "source"=>nil, "status"=>"500", "title"=>"Internal Server Error"}
Thank you @sosolidkk
- Added
links
Attribute inErrorSerializer
I don't think links
are required, that's why these were left out and I'd prefer to not enforce any members that aren't absolutely required by the spec.
The rest of the changes look good.
I don't think
links
are required, that's why these were left out and I'd prefer to not enforce any members that aren't absolutely required by the spec.
The code attribute is also not required but was added. The doc states that an error object MAY have the following members, and MUST contain at least one of those: id
, links
, status
, code
, title
, detail
, source
and meta
.
If we think about the requirement of those merbers, only the id
and status
could be enough for most cases.
In any case, if you'd prefer to not enforce it, I can revert the changes and keep only the other two.
What is the current behavior?
bundle exec rake spec
.links
attributes as per JSON:API Specification.What is the new behavior?
1. Solved an issue with Rails
secret_key_base
configI couldn't find any mention of
secrets
orsecrets.yml
in the project, and it also doesn't have an encrypted secrets file (credentials,secrets.yml.enc
), any.env
file or a in instruction on README to add the expect ENV var. Because of this, every time I tried to run the project, I encountered the following error:To address this, I updated the configuration to match what the Rails::Application object expects. Now, the specs and gem setup work correctly, allowing the tests and QA rake tasks to run as expected without any additional changes.
2. Resolved an Issue with the 422 Error Description
The Rack utils.rb defines the HTTP 422 error as Unprocessable Content, but the specs expect it to be Unprocessable Entity. I'm not entirely sure which is correct, but according to the specification, it should be Unprocessable Content. In any case, I've updated the specs to accept both.
3. Added
links
Attribute inErrorSerializer
I implemented a monkey patch in my app to provide this attribute, but I believe it should be included by default, similar to how the
code
attribute was previously added. Here's the specification reference for this attribute:Checklist
Please make sure the following requirements are complete: