Fix polymorphic belongs_to tests; passes on v0.10.5

This commit is contained in:
Benjamin Fleischer
2017-10-29 19:26:14 -05:00
parent 5e1e138d47
commit 0fcb8a6cce
2 changed files with 49 additions and 2 deletions

View File

@@ -165,6 +165,53 @@ module ActiveModel
assert_equal(expected, serialization(@picture, :json_api))
end
def test_json_api_serialization_with_polymorphic_belongs_to
expected = {
data: {
id: '1',
type: 'poly-tags',
attributes: { phrase: 'foo' },
relationships: {
:"object-tags" => {
data: [
{ id: '1', type: 'object-tags' },
{ id: '5', type: 'object-tags' }
]
}
}
},
included: [
{
id: '1',
type: 'object-tags',
relationships: {
taggable: {
data: { id: '42', type: 'employees' }
}
}
},
{
id: '42',
type: 'employees'
},
{
id: '5',
type: 'object-tags',
relationships: {
taggable: {
data: { id: '1', type: 'pictures' }
}
}
},
{
id: '1',
type: 'pictures'
}
]
}
assert_equal(expected, tag_serialization(:json_api))
end
end
end
end