mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 07:16:49 +00:00
Passes serializer options down into associations
This commit is contained in:
@@ -37,7 +37,7 @@ module ActiveModel
|
||||
@post.author = @author
|
||||
@author.posts = [@post]
|
||||
|
||||
@post_serializer = PostSerializer.new(@post)
|
||||
@post_serializer = PostSerializer.new(@post, {custom_options: true})
|
||||
@author_serializer = AuthorSerializer.new(@author)
|
||||
@comment_serializer = CommentSerializer.new(@comment)
|
||||
end
|
||||
@@ -65,6 +65,14 @@ module ActiveModel
|
||||
end
|
||||
end
|
||||
|
||||
def test_serializer_options_are_passed_into_associations_serializers
|
||||
@post_serializer.each_association do |name, association|
|
||||
if name == :comments
|
||||
assert association.first.custom_options[:custom_options]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_belongs_to
|
||||
assert_equal(
|
||||
{ post: { type: :belongs_to, association_options: {} },
|
||||
|
||||
Reference in New Issue
Block a user