Use association value for determining serializer used

Ensures overridden association value works when orignal association does not return a result.
This commit is contained in:
Mateo Murphy
2015-03-19 23:28:00 -04:00
parent 9058d5fce7
commit ca985e1afd
7 changed files with 20 additions and 11 deletions

View File

@@ -32,7 +32,7 @@ module ActiveModel
serializer = PostSerializer.new(@anonymous_post)
adapter = ActiveModel::Serializer::Adapter::Json.new(serializer)
assert_equal({title: "Hello!!", body: "Hello, world!!", id: 43, comments: [], blog: nil, author: nil}, adapter.serializable_hash)
assert_equal({title: "Hello!!", body: "Hello, world!!", id: 43, comments: [], blog: {id: 999, name: "Custom blog"}, author: nil}, adapter.serializable_hash)
end
end
end

View File

@@ -45,7 +45,10 @@ module ActiveModel
id: 1,
name: "Steve K."
},
blog: nil
blog: {
id: 999,
name: "Custom blog"
}
}]
assert_equal expected, @adapter.serializable_hash
end