mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 07:16:49 +00:00
add fields to adapter initialize function, pull in master, add tests using includes with fields
This commit is contained in:
@@ -40,6 +40,14 @@ module ActiveModel
|
||||
], @adapter.serializable_hash[:linked][:comments])
|
||||
end
|
||||
|
||||
def test_limit_fields_of_linked_comments
|
||||
@adapter = ActiveModel::Serializer::Adapter::JsonApi.new(@serializer, include: 'comments', fields: {comment: [:body]})
|
||||
assert_equal([
|
||||
{body: 'ZOMG A COMMENT'},
|
||||
{body: 'ZOMG ANOTHER COMMENT'}
|
||||
], @adapter.serializable_hash[:linked][:comments])
|
||||
end
|
||||
|
||||
def test_no_include_linked_if_comments_is_empty
|
||||
serializer = PostSerializer.new(@post_without_comments)
|
||||
adapter = ActiveModel::Serializer::Adapter::JsonApi.new(serializer)
|
||||
|
||||
Reference in New Issue
Block a user