simple_jsonapi_rails 1.2.0 → 1.3.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
  SHA256:
3
- metadata.gz: e4f215ae2299e394ec1979de2ee91292f5628834f7202bcb9331de60325ee7e5
4
- data.tar.gz: a685301d7e02ae0824907b4f958ca160a33a4817874fb7b3b094560ee282a080
3
+ metadata.gz: d9758a0f3fd06b470a59b9ab25ca7817645864ac816733172b63671fee1c3a4f
4
+ data.tar.gz: 24ff4b62b70c2883605e6440ee88306869b5c45e4c69ff6220a64fb28f85e3c7
5
5
  SHA512:
6
- metadata.gz: '08c57a2fcce220afef37833a229c291c24db7d62203f459134c94cddbc6756b7bf0f38f17aedd1f5792666f51b38fadd04cdd73ebbc9d5638f5ea24b09ad21e1'
7
- data.tar.gz: a855937c2a603fbe944cc0893e73a6ac45f5b171e5c0133a19aaa30d7810c0dd6fe41bd4106547f99c33b0704017d753bb552cb2adb6da835f95ee92296c8aed
6
+ metadata.gz: 30ca70b05fc1f6fd927a360ea94c94ac80b7d18320a5d89c1e0b806831c3597296f4d4805e3148732bedd20dc3edcd0d135c22c932049c32e324d9d59004a2f4
7
+ data.tar.gz: 4e94601dfcd208569e1cbfeb8691e6198f08d7569445220e7d974e43223eb336a036c86322c9a4d55be382d78a19e69886c45cf68589a2f5b67c1b0b8b4b79ab
@@ -1,3 +1,6 @@
1
+ ## Version 1.3.0 - February 28, 2020
2
+ * Fixing deprecation warning about media_type
3
+
1
4
  ## Version 1.2.0 - September 9, 2019
2
5
  * Adding support for Rails 6
3
6
 
@@ -4,7 +4,7 @@ module SimpleJsonapi
4
4
  class RequestValidator
5
5
  attr_reader :request, :params
6
6
 
7
- delegate :body, :content_type, :accept, :path, to: :request, prefix: true
7
+ delegate :body, :content_type, :media_type, :accept, :path, to: :request, prefix: true
8
8
 
9
9
  def initialize(request, params)
10
10
  @request = request
@@ -12,7 +12,11 @@ module SimpleJsonapi
12
12
  end
13
13
 
14
14
  def valid_content_type_header?
15
- !request_has_body? || request_content_type == SimpleJsonapi::MIME_TYPE
15
+ if request.respond_to?(:media_type)
16
+ !request_has_body? || request_media_type == SimpleJsonapi::MIME_TYPE
17
+ else
18
+ !request_has_body? || request_content_type == SimpleJsonapi::MIME_TYPE
19
+ end
16
20
  end
17
21
 
18
22
  def valid_accept_header?
@@ -14,17 +14,32 @@ module SimpleJsonapi
14
14
  # In the renderers, `self` is the controller
15
15
 
16
16
  ::ActionController::Renderers.add(:jsonapi_resource) do |resource, options|
17
- self.content_type ||= Mime[:jsonapi]
17
+ if respond_to?(:media_type)
18
+ self.content_type = Mime[:jsonapi] unless self.media_type
19
+ else
20
+ self.content_type ||= Mime[:jsonapi]
21
+ end
22
+
18
23
  SimpleJsonapi.render_resource(resource, options).to_json
19
24
  end
20
25
 
21
26
  ::ActionController::Renderers.add(:jsonapi_resources) do |resources, options|
22
- self.content_type ||= Mime[:jsonapi]
27
+ if respond_to?(:media_type)
28
+ self.content_type = Mime[:jsonapi] unless self.media_type
29
+ else
30
+ self.content_type ||= Mime[:jsonapi]
31
+ end
32
+
23
33
  SimpleJsonapi.render_resources(resources, options).to_json
24
34
  end
25
35
 
26
36
  ::ActionController::Renderers.add(:jsonapi_errors) do |errors, options|
27
- self.content_type ||= Mime[:jsonapi]
37
+ if respond_to?(:media_type)
38
+ self.content_type = Mime[:jsonapi] unless self.media_type
39
+ else
40
+ self.content_type ||= Mime[:jsonapi]
41
+ end
42
+
28
43
  SimpleJsonapi.render_errors(errors, options).to_json
29
44
  end
30
45
  end
@@ -1,5 +1,5 @@
1
1
  module SimpleJsonapi
2
2
  module Rails
3
- VERSION = '1.2.0'.freeze
3
+ VERSION = '1.3.0'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_jsonapi_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - PatientsLikeMe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-09-09 00:00:00.000000000 Z
11
+ date: 2020-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: simple_jsonapi
@@ -234,6 +234,7 @@ files:
234
234
  - test/action_controller_test.rb
235
235
  - test/dummy/.gitignore
236
236
  - test/dummy/Rakefile
237
+ - test/dummy/app/assets/config/manifest.js
237
238
  - test/dummy/app/controllers/api_controller.rb
238
239
  - test/dummy/app/controllers/orders/relationships/items_controller.rb
239
240
  - test/dummy/app/controllers/orders_controller.rb
@@ -280,8 +281,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
280
281
  - !ruby/object:Gem::Version
281
282
  version: '0'
282
283
  requirements: []
283
- rubyforge_project:
284
- rubygems_version: 2.7.6
284
+ rubygems_version: 3.0.6
285
285
  signing_key:
286
286
  specification_version: 4
287
287
  summary: A library for integrating SimpleJsonapi into a Rails application.
@@ -289,6 +289,7 @@ test_files:
289
289
  - test/action_controller_test.rb
290
290
  - test/dummy/.gitignore
291
291
  - test/dummy/Rakefile
292
+ - test/dummy/app/assets/config/manifest.js
292
293
  - test/dummy/app/controllers/api_controller.rb
293
294
  - test/dummy/app/controllers/orders/relationships/items_controller.rb
294
295
  - test/dummy/app/controllers/orders_controller.rb