jsonapi-serializers 0.11.0 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b670315a342425c1d55f313aa4bc0830e1b0a69e
4
- data.tar.gz: d2be33728c559adbee37316b70087369d5513389
3
+ metadata.gz: 7cff13da1ad649652014dfc451176436fcde50ba
4
+ data.tar.gz: 46c974244da10f13881c8a0de5ea63eec2c2ec04
5
5
  SHA512:
6
- metadata.gz: 70dc34dd00b999e5805012212e80daa22510a2665b77366e657c6e809a7812ca143af7db8789fb88fe9a590f5c343bd25a164fee1903da79f74df0d52fb186d6
7
- data.tar.gz: e254988e99b57b4108c7cecf35e065751b164722dc751fb14bdf46818f8922a3162c7780b3479625450a21d41872005411c6fbe2a6bfa56c6778a41a5f926ae0
6
+ metadata.gz: 2746b67e07e94155403e8740932d8f0a6f0df161208e6a3602346be71350cb0cd11b84dfb3d710e8008cf5582650b6f2e25058286aba8984be92acf95be479bd
7
+ data.tar.gz: dcc38f840609ef7730e7c84f11bc613092935b156b1786cb16b9314caafe8d1d9854b2d40c376badf0a447fcc6f031074a364e0e45625c0cac2338a17c710d99
@@ -9,8 +9,8 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ["Mike Fotinakis"]
10
10
  spec.email = ["mike@fotinakis.com"]
11
11
  spec.summary = %q{Pure Ruby readonly serializers for the JSON:API spec.}
12
- spec.description = %q{}
13
- spec.homepage = ""
12
+ spec.description = %q{Pure Ruby readonly serializers for the JSON:API spec.}
13
+ spec.homepage = "https://github.com/fotinakis/jsonapi-serializers"
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.files = `git ls-files -z`.split("\x0")
@@ -359,10 +359,15 @@ module JSONAPI
359
359
 
360
360
  serializer = serializer_class.new(object, options)
361
361
  data = {
362
- 'id' => serializer.id.to_s,
363
362
  'type' => serializer.type.to_s,
364
363
  }
365
364
 
365
+ # "The id member is not required when the resource object originates at the client
366
+ # and represents a new resource to be created on the server."
367
+ # http://jsonapi.org/format/#document-resource-objects
368
+ # We'll assume that if the id is blank, it means the resource is to be created.
369
+ data['id'] = serializer.id.to_s if serializer.id && !serializer.id.empty?
370
+
366
371
  # Merge in optional top-level members if they are non-nil.
367
372
  # http://jsonapi.org/format/#document-structure-resource-objects
368
373
  # Call the methods once now to avoid calling them twice when evaluating the if's below.
@@ -1,5 +1,5 @@
1
1
  module JSONAPI
2
2
  module Serializer
3
- VERSION = '0.11.0'
3
+ VERSION = '0.12.0'
4
4
  end
5
5
  end
@@ -129,6 +129,22 @@ describe JSONAPI::Serializer do
129
129
  },
130
130
  })
131
131
  end
132
+ it 'does not include id when it is nil' do
133
+ post = create(:post)
134
+ post.id = nil
135
+ primary_data = serialize_primary(post, {serializer: MyApp::PostSerializerWithoutLinks})
136
+ expect(primary_data).to eq({
137
+ 'type' => 'posts',
138
+ 'attributes' => {
139
+ 'title' => 'Title for Post 1',
140
+ 'long-content' => 'Body for Post 1',
141
+ },
142
+ 'relationships' => {
143
+ 'author' => {},
144
+ 'long-comments' => {},
145
+ },
146
+ })
147
+ end
132
148
  it 'serializes object when multiple attributes are declared once' do
133
149
  post = create(:post)
134
150
  primary_data = serialize_primary(post, {serializer: MyApp::MultipleAttributesSerializer})
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jsonapi-serializers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Fotinakis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-27 00:00:00.000000000 Z
11
+ date: 2016-05-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -94,7 +94,7 @@ dependencies:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: '4.2'
97
- description: ''
97
+ description: Pure Ruby readonly serializers for the JSON:API spec.
98
98
  email:
99
99
  - mike@fotinakis.com
100
100
  executables: []
@@ -117,7 +117,7 @@ files:
117
117
  - spec/spec_helper.rb
118
118
  - spec/support/factory.rb
119
119
  - spec/support/serializers.rb
120
- homepage: ''
120
+ homepage: https://github.com/fotinakis/jsonapi-serializers
121
121
  licenses:
122
122
  - MIT
123
123
  metadata: {}
@@ -137,7 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
137
137
  version: '0'
138
138
  requirements: []
139
139
  rubyforge_project:
140
- rubygems_version: 2.4.5
140
+ rubygems_version: 2.2.2
141
141
  signing_key:
142
142
  specification_version: 4
143
143
  summary: Pure Ruby readonly serializers for the JSON:API spec.
@@ -146,4 +146,3 @@ test_files:
146
146
  - spec/spec_helper.rb
147
147
  - spec/support/factory.rb
148
148
  - spec/support/serializers.rb
149
- has_rdoc: