mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 15:23:06 +00:00
Support overriding association methods
You can override associations to define custom scope on them.
This commit is contained in:
@@ -24,6 +24,8 @@ module ActiveModel
|
||||
@blog = Blog.new(id: 1, name: "My Blog!!")
|
||||
@blog.writer = @author
|
||||
@blog.articles = [@post]
|
||||
@post.blog = @blog
|
||||
@post_without_comments.blog = nil
|
||||
|
||||
@serializer = PostSerializer.new(@post)
|
||||
@adapter = ActiveModel::Serializer::Adapter::JsonApi.new(@serializer)
|
||||
@@ -32,7 +34,7 @@ module ActiveModel
|
||||
def test_includes_comment_ids
|
||||
assert_equal(["1", "2"], @adapter.serializable_hash[:posts][:links][:comments])
|
||||
end
|
||||
|
||||
|
||||
def test_includes_linked_comments
|
||||
@adapter = ActiveModel::Serializer::Adapter::JsonApi.new(@serializer, include: 'comments')
|
||||
expected = [{
|
||||
|
||||
Reference in New Issue
Block a user