spec/serializer_spec.rb in jsonapi-serializers-0.1.1 vs spec/serializer_spec.rb in jsonapi-serializers-0.1.2

- old
+ new

@@ -23,10 +23,11 @@ 'long-content' => 'Body for Post 1', }, 'links' => { 'self' => '/posts/1', }, + 'relationships' => {}, }) end it 'can serialize primary data for a simple object with a long name' do long_comment = create(:long_comment, post: create(:post)) primary_data = serialize_primary(long_comment, {serializer: MyApp::LongCommentSerializer}) @@ -36,10 +37,12 @@ 'attributes' => { 'body' => 'Body for LongComment 1', }, 'links' => { 'self' => '/long-comments/1', + }, + 'relationships' => { 'user' => { 'self' => '/long-comments/1/links/user', 'related' => '/long-comments/1/user', }, 'post' => { @@ -60,10 +63,11 @@ 'long-content' => 'Body for Post 1', }, 'links' => { 'self' => '/posts/1', }, + 'relationships' => {}, 'meta' => { 'copyright' => 'Copyright 2015 Example Corp.', 'authors' => [ 'Aliens', ], @@ -81,10 +85,12 @@ 'title' => 'Title for Post 1', 'long-content' => 'Body for Post 1', }, 'links' => { 'self' => '/posts/1', + }, + 'relationships' => { # Both to-one and to-many links are present, but neither include linkage: 'author' => { 'self' => '/posts/1/links/author', 'related' => '/posts/1/author', }, @@ -111,10 +117,12 @@ 'title' => 'Title for Post 1', 'long-content' => 'Body for Post 1', }, 'links' => { 'self' => '/posts/1', + }, + 'relationships' => { 'author' => { 'self' => '/posts/1/links/author', 'related' => '/posts/1/author', # Spec: Resource linkage MUST be represented as one of the following: # - null for empty to-one relationships. @@ -143,10 +151,12 @@ 'title' => 'Title for Post 1', 'long-content' => 'Body for Post 1', }, 'links' => { 'self' => '/posts/1', + }, + 'relationships' => { 'author' => { 'self' => '/posts/1/links/author', 'related' => '/posts/1/author', # Spec: Resource linkage MUST be represented as one of the following: # - a 'linkage object' (defined below) for non-empty to-one relationships. @@ -178,10 +188,12 @@ 'title' => 'Title for Post 1', 'long-content' => 'Body for Post 1', }, 'links' => { 'self' => '/posts/1', + }, + 'relationships' => { 'author' => { 'self' => '/posts/1/links/author', 'related' => '/posts/1/author', 'linkage' => nil, }, @@ -211,10 +223,12 @@ 'title' => 'Title for Post 1', 'long-content' => 'Body for Post 1', }, 'links' => { 'self' => '/posts/1', + }, + 'relationships' => { 'author' => { 'self' => '/posts/1/links/author', 'related' => '/posts/1/author', 'linkage' => nil, }, @@ -412,10 +426,10 @@ # Only the author is included: serialize_primary(post.author, {serializer: MyApp::UserSerializer}), ], } includes = ['long-comments.post.author'] - actual_data = JSONAPI::Serializer.serialize(post, include: ['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']) expect(actual_data).to eq(expected_data) end \ No newline at end of file