Refactor ActiveModel::ErrorSerializer#98
Merged
stas merged 4 commits intostas:masterfrom Jun 23, 2024
Merged
Conversation
2e64896 to
f0b9dbd
Compare
Test Ruby 3.3 and Rails 6.1 instead
The previous specs were harder to read, and they relied on the ordering of the errors, which is unnecessary.
We're only running CI for Rails 6.1+ now, and we can now rely on a stable API for ActiveModel::Errors.
f0b9dbd to
89f6e61
Compare
3 tasks
3 tasks
lilasquared
reviewed
Jul 15, 2024
|
|
||
| attribute :source do |object, params| | ||
| error_key, _ = object | ||
| error_key = object.attribute |
There was a problem hiding this comment.
it seems before this change an array was supported here as object but now it is not. Is there a reason for the change in behavior there?
Contributor
Author
There was a problem hiding this comment.
No, that was certainly not intended, but there was also no test for it. If you depend on that behaviour, as a spec and an Array.wrap or similar as a PR.
There was a problem hiding this comment.
if this is more correct i can update on my end. we were building up these errors manually (for some unknown reason) which this suddenly broke.
Contributor
Author
|
I'm not the maintainer, just did this particular refactoring. So that
decision would be on you and @stas.
Aaron Roberts ***@***.***> schrieb am Mo., 15. Juli 2024,
19:26:
… ***@***.**** commented on this pull request.
------------------------------
In lib/jsonapi/active_model_error_serializer.rb
<#98 (comment)>:
> end
attribute :source do |object, params|
- error_key, _ = object
+ error_key = object.attribute
if this is more correct i can update on my end. we were building up these
errors manually (for some unknown reason) which this suddenly broke.
—
Reply to this email directly, view it on GitHub
<#98 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAFLXKJTQNT4EJVGWFJCK4TZMPIHJAVCNFSM6AAAAABJYJ4CW2VHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDCNZXG44TGNJSGQ>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is the current behavior?
No behavior change, but the ActiveModel::ErrorSerializer reads much nicer.
Checklist
Please make sure the following requirements are complete:
features)