-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Root option with empty array support #1013
Conversation
@@ -39,15 +45,52 @@ def test_meta_and_meta_key_attr_readers | |||
assert_equal @serializer.meta_key, "the meta key" | |||
end | |||
|
|||
def test_json_key_when_resource_is_empty |
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.
@vyrak I would like to keep this test, it's testing a totaly different thing.
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.
Isn't that a duplicated by https://github.com/rails-api/active_model_serializers/pull/1013/files#diff-4511bb323b8555a8103c7964418e0e40R69? I favored that version because it doesn't modify the Array class itself.
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.
Nops, it was introduced on #1007
The json_key will become 'postcomments' rather than 'post_comments'.
Using 'underscore' instead of 'downcase' fixes the error.
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.
Maybe I'm being slow and missing your point, in the build_named_collection
helper method, it's returning an instance with a name of "MeResource"
which gets underscored & pluralized to "me_resources"
.
If I understand #1007 correctly, it was a problem with an empty collection object with a name
not getting transformed properly. I believe that test_json_key_with_resource_with_name_and_no_serializers
is effectively testing that case, right?
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.
Oh you are right, I didn't realized that, sorry 😁
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.
Ah, all good. The test name might've been what was confusing. Maybe it makes more sense to say test_json_key_with_empty_resource_with_name
instead of test_json_key_with_resource_with_name_and_no_serializers
. Though it looks like you already merged.
@vyrak great work! I was about to pick that up, but I'm glad you made it! |
LGTM, I'm merging it and |
Root option with empty array support
based off #987
support for
:root
option along with empty array fix