Support overriding association methods

You can override associations to define custom scope on them.
This commit is contained in:
Alexandre de Oliveira
2015-01-29 16:48:41 -02:00
parent 652493848a
commit e47231cdc8
15 changed files with 106 additions and 13 deletions

View File

@@ -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 = [{