This commit is contained in:
groyoh
2015-05-17 22:47:44 +02:00
parent 46ae776175
commit a794a06fa5
4 changed files with 28 additions and 1 deletions

View File

@@ -22,6 +22,20 @@ module ActiveModel
ActionController::Base.cache_store.clear
end
def test_with_serializer_option
@blog.special_attribute = "Special"
@blog.articles = [@first_post, @second_post]
@serializer = ArraySerializer.new([@blog], serializer: CustomBlogSerializer)
@adapter = ActiveModel::Serializer::Adapter::Json.new(@serializer)
expected = [{
id: 1,
special_attribute: "Special",
articles: [{id: 1,title: "Hello!!", body: "Hello, world!!"}, {id: 2, title: "New Post", body: "Body"}]
}]
assert_equal expected, @adapter.serializable_hash
end
def test_include_multiple_posts
expected = [{
title: "Hello!!",