jsonapi-resources 0.5.2 → 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/jsonapi/request.rb +5 -4
- data/lib/jsonapi/resources/version.rb +1 -1
- data/test/controllers/controller_test.rb +12 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1484af26137219f05b85088a8ffcdf07c7bfd4d3
|
4
|
+
data.tar.gz: 3b8441b43cab89ec1701343027d9308d8a9c523d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a900be54a2ba2b6d3d4bba35e845960f50f4fae790a7b89168100419d1bb3451437acfd2700f5cbc309c52432e4980f059fc72eef628e9cbeaa19af7c66d8885
|
7
|
+
data.tar.gz: 9698bf894815ee7b0a261bb7985c0cdf93a33083a1b640728cdbf7ad4850d1daca2ec3d5cfca2abe7635888a3a58e7e4c375f3c58877179ef2a07b6961c85a6d
|
data/lib/jsonapi/request.rb
CHANGED
@@ -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
|
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
|
-
|
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
|
@@ -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.
|
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-
|
12
|
+
date: 2015-07-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|