jsonapi-resources 0.5.2 → 0.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 50581a29495af11bb597deb7c7ca7369eb084b77
4
- data.tar.gz: 07aff054fd599cfa81fd11c3934900cce12f2317
3
+ metadata.gz: 1484af26137219f05b85088a8ffcdf07c7bfd4d3
4
+ data.tar.gz: 3b8441b43cab89ec1701343027d9308d8a9c523d
5
5
  SHA512:
6
- metadata.gz: 626ce6b524027111ef04fed7988313018cb9daa9eda844bf2a05b7cd5b7acf8b45c0dd213aafbeb13dff473a50180037c434a5715092bb624801e3cca1cc5e06
7
- data.tar.gz: e08ff693bb02c582ff4685d209c0fee6e7d5fbd0dce21a6b43b614103d4d98ae0c2eba60ae63eafda808d79ef02b10e18faf2d38b81b978e65fd5ec6b8e14328
6
+ metadata.gz: a900be54a2ba2b6d3d4bba35e845960f50f4fae790a7b89168100419d1bb3451437acfd2700f5cbc309c52432e4980f059fc72eef628e9cbeaa19af7c66d8885
7
+ data.tar.gz: 9698bf894815ee7b0a261bb7985c0cdf93a33083a1b640728cdbf7ad4850d1daca2ec3d5cfca2abe7635888a3a58e7e4c375f3c58877179ef2a07b6961c85a6d
@@ -104,7 +104,7 @@ module JSONAPI
104
104
  def setup_update_action(params)
105
105
  parse_fields(params[:fields])
106
106
  parse_include_directives(params[:include])
107
- parse_replace_operation(params.require(:data), params.require(:id))
107
+ parse_replace_operation(params.require(:data), params[:id])
108
108
  end
109
109
 
110
110
  def setup_destroy_action(params)
@@ -563,7 +563,7 @@ module JSONAPI
563
563
  end
564
564
  end
565
565
 
566
- def parse_single_replace_operation(data, keys)
566
+ def parse_single_replace_operation(data, keys, id_key_presence_check_required: true)
567
567
  fail JSONAPI::Exceptions::MissingKey.new if data[:id].nil?
568
568
 
569
569
  type = data[:type]
@@ -572,7 +572,7 @@ module JSONAPI
572
572
  end
573
573
 
574
574
  key = data[:id]
575
- unless keys.include?(key)
575
+ if id_key_presence_check_required && !keys.include?(key)
576
576
  fail JSONAPI::Exceptions::KeyNotIncludedInURL.new(key)
577
577
  end
578
578
 
@@ -596,7 +596,8 @@ module JSONAPI
596
596
  parse_single_replace_operation(object_params, keys)
597
597
  end
598
598
  else
599
- parse_single_replace_operation(data, [keys])
599
+ parse_single_replace_operation(data, [keys],
600
+ id_key_presence_check_required: keys.present?)
600
601
  end
601
602
 
602
603
  rescue JSONAPI::Exceptions::Error => e
@@ -1,5 +1,5 @@
1
1
  module JSONAPI
2
2
  module Resources
3
- VERSION = '0.5.2'
3
+ VERSION = '0.5.3'
4
4
  end
5
5
  end
@@ -2100,6 +2100,18 @@ class Api::V2::PreferencesControllerTest < ActionController::TestCase
2100
2100
  get :show
2101
2101
  assert_response :success
2102
2102
  end
2103
+
2104
+ def test_update_singleton_resource_without_id
2105
+ set_content_type_header!
2106
+ patch :update,
2107
+ data: {
2108
+ id: "1",
2109
+ type: "preferences",
2110
+ attributes: {
2111
+ }
2112
+ }
2113
+ assert_response :success
2114
+ end
2103
2115
  end
2104
2116
 
2105
2117
  class Api::V1::PostsControllerTest < ActionController::TestCase
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jsonapi-resources
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Gebhardt
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-07-28 00:00:00.000000000 Z
12
+ date: 2015-07-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler