Fix tests to comply with the JSON API spec.

This commit is contained in:
Lucas Hosseini 2016-04-20 03:08:54 +02:00
parent 7485c8487e
commit ebda34b3d3
3 changed files with 9 additions and 6 deletions

View File

@ -131,8 +131,9 @@ module ActiveModelSerializers
id: '1',
type: 'virtual-values',
relationships: {
maker: { data: { id: 1 } },
reviews: { data: [{ id: 1 }, { id: 2 }] }
maker: { data: { type: 'makers', id: '1' } },
reviews: { data: [{ type: 'reviews', id: '1' },
{ type: 'reviews', id: '2' }] }
}
}
}, adapter.serializable_hash)

View File

@ -65,8 +65,9 @@ module ActiveModelSerializers
id: '1',
type: 'virtual-values',
relationships: {
maker: { data: { id: 1 } },
reviews: { data: [{ id: 1 }, { id: 2 }] }
maker: { data: { type: 'makers', id: '1' } },
reviews: { data: [{ type: 'reviews', id: '1' },
{ type: 'reviews', id: '2' }] }
}
}
}

View File

@ -227,8 +227,9 @@ end
VirtualValueSerializer = Class.new(ActiveModel::Serializer) do
attributes :id
has_many :reviews, virtual_value: [{ id: 1 }, { id: 2 }]
has_one :maker, virtual_value: { id: 1 }
has_many :reviews, virtual_value: [{ type: 'reviews', id: '1' },
{ type: 'reviews', id: '2' }]
has_one :maker, virtual_value: { type: 'makers', id: '1' }
def reviews
end