mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-22 22:06:50 +00:00
Merge pull request #821 from wjordan/patch-1
Fix explicit serializer for associations
This commit is contained in:
commit
77fb050d24
@ -176,7 +176,7 @@ module ActiveModel
|
||||
|
||||
def serializer_from_options(options)
|
||||
opts = {}
|
||||
serializer = options.fetch(:options, {}).fetch(:serializer, nil)
|
||||
serializer = options.fetch(:association_options, {}).fetch(:serializer, nil)
|
||||
opts[:serializer] = serializer if serializer
|
||||
opts
|
||||
end
|
||||
|
||||
@ -34,8 +34,9 @@ module ActiveModel
|
||||
end
|
||||
|
||||
def test_includes_linked_comments
|
||||
assert_equal([{ id: '1', body: "ZOMG A COMMENT", links: { post: @post.id.to_s, author: nil }},
|
||||
{ id: '2', body: "ZOMG ANOTHER COMMENT", links: { post: @post.id.to_s, author: nil }}],
|
||||
# If CommentPreviewSerializer is applied correctly the body text will not be present in the output
|
||||
assert_equal([{ id: '1', links: { post: @post.id.to_s}},
|
||||
{ id: '2', links: { post: @post.id.to_s}}],
|
||||
@adapter.serializable_hash[:linked][:comments])
|
||||
end
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user