spec/serializer_spec.rb in jsonapi-serializers-1.0.0 vs spec/serializer_spec.rb in jsonapi-serializers-1.0.1

- old
+ new

@@ -706,11 +706,14 @@ post = create(:post, :with_author, long_comments: long_comments) # Make sure each long-comment has a circular reference back to the post. long_comments.each { |c| c.post = post } expected_data = { - 'data' => serialize_primary(post, {serializer: MyApp::PostSerializer}), + 'data' => serialize_primary(post, { + serializer: MyApp::PostSerializer, + include_linkages: ['long-comments'] + }), 'included' => [ # Intermediates are included: long-comments, long-comments.post, and long-comments.post.author # http://jsonapi.org/format/#document-structure-compound-documents serialize_primary(post.long_comments.first, { serializer: MyApp::LongCommentSerializer, @@ -743,11 +746,14 @@ post = create(:post, :with_author, long_comments: long_comments) # Make sure each long-comment has a circular reference back to the post. long_comments.each { |c| c.post = post } expected_data = { - 'data' => serialize_primary(post, {serializer: MyApp::PostSerializer}), + 'data' => serialize_primary(post, { + serializer: MyApp::PostSerializer, + include_linkages: ['long-comments'] + }), 'included' => [ serialize_primary(first_comment, { serializer: MyApp::LongCommentSerializer, include_linkages: ['user'] }), @@ -786,11 +792,11 @@ }), # Note: post.author does not show up here because it was not included. serialize_primary(comment_user, {serializer: MyAppOtherNamespace::UserSerializer}), ], } - includes = ['long-comments', 'long-comments.user'] + includes = ['long-comments.user'] actual_data = JSONAPI::Serializer.serialize(post, include: includes) # Multiple expectations for better diff output for debugging. expect(actual_data['data']).to eq(expected_data['data']) expect(actual_data['included']).to eq(expected_data['included']) @@ -824,11 +830,11 @@ }), serialize_primary(post.author, {serializer: MyAppOtherNamespace::UserSerializer}), ], } # Also test that it handles string include arguments. - includes = 'long-comments, long-comments.post.author' + includes = 'long-comments,long-comments.post.author' actual_data = JSONAPI::Serializer.serialize(post, include: includes) # Multiple expectations for better diff output for debugging. expect(actual_data['data']).to eq(expected_data['data']) expect(actual_data['included']).to eq(expected_data['included']) @@ -1195,10 +1201,13 @@ post = create(:post, :with_author, long_comments: long_comments) # Make sure each long-comment has a circular reference back to the post. long_comments.each { |c| c.post = post } expected_data = { - 'data' => serialize_primary(post, {serializer: Api::V1::MyApp::PostSerializer}), + 'data' => serialize_primary(post, { + serializer: Api::V1::MyApp::PostSerializer, + include_linkages: ['long-comments'] + }), 'included' => [ # Intermediates are included: long-comments, long-comments.post, and long-comments.post.author # http://jsonapi.org/format/#document-structure-compound-documents serialize_primary(post.long_comments.first, { serializer: Api::V1::MyApp::LongCommentSerializer,