Serializers now inherit attributes

This commit is contained in:
Yohan Robert
2015-04-08 16:51:28 +02:00
committed by groyoh
parent 1577969cb7
commit 02ffff599f
4 changed files with 57 additions and 4 deletions

View File

@@ -101,6 +101,27 @@ module ActiveModel
assert blog_is_present
end
def test_associations_inheritance
inherited_klass = Class.new(PostSerializer)
assert_equal(PostSerializer._associations, inherited_klass._associations)
end
def test_associations_inheritance_with_new_association
inherited_klass = Class.new(PostSerializer) do
has_many :top_comments, serializer: CommentSerializer
end
expected_associations = PostSerializer._associations.merge(
top_comments: {
type: :has_many,
association_options: {
serializer: CommentSerializer
}
}
)
assert_equal(inherited_klass._associations, expected_associations)
end
end
end
end