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

- old
+ new

@@ -40,16 +40,20 @@ 'links' => { 'self' => '/long-comments/1', }, 'relationships' => { 'user' => { - 'self' => '/long-comments/1/links/user', - 'related' => '/long-comments/1/user', + 'links' => { + 'self' => '/long-comments/1/links/user', + 'related' => '/long-comments/1/user', + }, }, 'post' => { - 'self' => '/long-comments/1/links/post', - 'related' => '/long-comments/1/post', + 'links' => { + 'self' => '/long-comments/1/links/post', + 'related' => '/long-comments/1/post', + }, }, }, }) end it 'can serialize primary data for a simple object with resource-level metadata' do @@ -89,16 +93,20 @@ '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', + 'links' => { + 'self' => '/posts/1/links/author', + 'related' => '/posts/1/author', + }, }, 'long-comments' => { - 'self' => '/posts/1/links/long-comments', - 'related' => '/posts/1/long-comments', + 'links' => { + 'self' => '/posts/1/links/long-comments', + 'related' => '/posts/1/long-comments', + }, }, }, }) end end @@ -120,21 +128,25 @@ 'links' => { 'self' => '/posts/1', }, 'relationships' => { 'author' => { - 'self' => '/posts/1/links/author', - 'related' => '/posts/1/author', + 'links' => { + '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. # http://jsonapi.org/format/#document-structure-resource-relationships - 'linkage' => nil, + 'data' => nil, }, 'long-comments' => { - 'self' => '/posts/1/links/long-comments', - 'related' => '/posts/1/long-comments', - 'linkage' => [], + 'links' => { + 'self' => '/posts/1/links/long-comments', + 'related' => '/posts/1/long-comments', + }, + 'data' => [], }, }, }) end it 'can serialize primary data for a simple to-one relationship' do @@ -154,24 +166,28 @@ 'links' => { 'self' => '/posts/1', }, 'relationships' => { 'author' => { - 'self' => '/posts/1/links/author', - 'related' => '/posts/1/author', + 'links' => { + '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. # http://jsonapi.org/format/#document-structure-resource-relationships - 'linkage' => { + 'data' => { 'type' => 'users', 'id' => '1', }, }, 'long-comments' => { - 'self' => '/posts/1/links/long-comments', - 'related' => '/posts/1/long-comments', - 'linkage' => [], + 'links' => { + 'self' => '/posts/1/links/long-comments', + 'related' => '/posts/1/long-comments', + }, + 'data' => [], }, }, }) end it 'can serialize primary data for an empty to-many relationship' do @@ -191,21 +207,25 @@ 'links' => { 'self' => '/posts/1', }, 'relationships' => { 'author' => { - 'self' => '/posts/1/links/author', - 'related' => '/posts/1/author', - 'linkage' => nil, + 'links' => { + 'self' => '/posts/1/links/author', + 'related' => '/posts/1/author', + }, + 'data' => nil, }, 'long-comments' => { - 'self' => '/posts/1/links/long-comments', - 'related' => '/posts/1/long-comments', + 'links' => { + 'self' => '/posts/1/links/long-comments', + 'related' => '/posts/1/long-comments', + }, # Spec: Resource linkage MUST be represented as one of the following: # - an empty array ([]) for empty to-many relationships. # http://jsonapi.org/format/#document-structure-resource-relationships - 'linkage' => [], + 'data' => [], }, }, }) end it 'can serialize primary data for a simple to-many relationship' do @@ -226,20 +246,24 @@ 'links' => { 'self' => '/posts/1', }, 'relationships' => { 'author' => { - 'self' => '/posts/1/links/author', - 'related' => '/posts/1/author', - 'linkage' => nil, + 'links' => { + 'self' => '/posts/1/links/author', + 'related' => '/posts/1/author', + }, + 'data' => nil, }, 'long-comments' => { - 'self' => '/posts/1/links/long-comments', - 'related' => '/posts/1/long-comments', + 'links' => { + 'self' => '/posts/1/links/long-comments', + 'related' => '/posts/1/long-comments', + }, # Spec: Resource linkage MUST be represented as one of the following: # - an array of linkage objects for non-empty to-many relationships. # http://jsonapi.org/format/#document-structure-resource-relationships - 'linkage' => [ + 'data' => [ { 'type' => 'long-comments', 'id' => '1', }, { \ No newline at end of file