spec/serializer_spec.rb in jsonapi-serializers-0.11.0 vs spec/serializer_spec.rb in jsonapi-serializers-0.12.0
- old
+ new
@@ -127,9 +127,25 @@
'author' => {},
'long-comments' => {},
},
})
end
+ it 'does not include id when it is nil' do
+ post = create(:post)
+ post.id = nil
+ primary_data = serialize_primary(post, {serializer: MyApp::PostSerializerWithoutLinks})
+ expect(primary_data).to eq({
+ 'type' => 'posts',
+ 'attributes' => {
+ 'title' => 'Title for Post 1',
+ 'long-content' => 'Body for Post 1',
+ },
+ 'relationships' => {
+ 'author' => {},
+ 'long-comments' => {},
+ },
+ })
+ end
it 'serializes object when multiple attributes are declared once' do
post = create(:post)
primary_data = serialize_primary(post, {serializer: MyApp::MultipleAttributesSerializer})
expect(primary_data).to eq({
'id' => '1',