Add some failing tests around has_many assocs...

..where no serializer is defined for the thing that is has_many'd
This commit is contained in:
Justin Aiken
2015-06-12 15:05:33 -06:00
committed by João Moura
parent 189b79523c
commit 3710c32cee
4 changed files with 31 additions and 1 deletions

View File

@@ -17,6 +17,8 @@ module ActiveModel
@second_comment.post = @post
@blog = Blog.new(id: 1, name: "My Blog!!")
@post.blog = @blog
@tag = Tag.new(id: 1, name: "#hash_tag")
@post.tags = [@tag]
@serializer = PostSerializer.new(@post)
@adapter = ActiveModel::Serializer::Adapter::Json.new(@serializer)
@@ -28,9 +30,14 @@ module ActiveModel
{id: 2, body: 'ZOMG ANOTHER COMMENT'}
], @adapter.serializable_hash[:post][:comments])
end
def test_has_many_with_no_serializer
serializer = PostWithTagsSerializer.new(@post)
adapter = ActiveModel::Serializer::Adapter::Json.new(serializer)
assert_includes(adapter.as_json, :tags)
end
end
end
end
end
end

View File

@@ -27,6 +27,8 @@ module ActiveModel
@blog.articles = [@post]
@post.blog = @blog
@post_without_comments.blog = nil
@tag = Tag.new(id: 1, name: "#hash_tag")
@post.tags = [@tag]
@serializer = PostSerializer.new(@post)
@adapter = ActiveModel::Serializer::Adapter::JsonApi.new(@serializer)
@@ -103,6 +105,12 @@ module ActiveModel
}
assert_equal expected, actual
end
def test_has_many_with_no_serializer
serializer = PostWithTagsSerializer.new(@post)
adapter = ActiveModel::Serializer::Adapter::JsonApi.new(serializer)
assert_includes(adapter.serializable_hash, :tags)
end
end
end
end