fun_with_json_api 0.0.9 → 0.0.10
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 +4 -4
- data/lib/fun_with_json_api/attributes/relationship.rb +2 -2
- data/lib/fun_with_json_api/attributes/relationship_collection.rb +1 -1
- data/lib/fun_with_json_api/collection_manager.rb +1 -1
- data/lib/fun_with_json_api/find_resource_from_document.rb +1 -1
- data/lib/fun_with_json_api/schema_validators/check_collection_has_all_members.rb +1 -1
- data/lib/fun_with_json_api/schema_validators/check_collection_is_authorized.rb +1 -1
- data/lib/fun_with_json_api/schema_validators/check_resource_is_authorized.rb +4 -4
- data/lib/fun_with_json_api/version.rb +1 -1
- data/spec/dummy/log/test.log +7755 -0
- data/spec/fun_with_json_api/collection_manager_spec.rb +7 -7
- data/spec/fun_with_json_api/deserializer_spec.rb +5 -5
- data/spec/fun_with_json_api/find_collection_from_document_spec.rb +6 -6
- data/spec/fun_with_json_api/find_resource_from_document_spec.rb +2 -2
- data/spec/fun_with_json_api_spec.rb +2 -2
- 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: a119836d10ecb97a0691d85556e582a806c46586
|
4
|
+
data.tar.gz: 18e1f85f672338ad34f9766d7e184a78e6bcca61
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a237a4953d522efb48caf822ad83e38d61292199e12df4a527e1ab9ee4c1c4bf06b37cafa51f5ca557dc9f9ee87af16514b7a18760ddef5745e1b2b1b2537350
|
7
|
+
data.tar.gz: 90895829f7b851d0c5f6acc0b9cfdc6a4c16f73c87ffacdff68bf3069cc853e5bdfc7e84c613125b97d6a4dfae95c5f7b04dade005cc174f6f35b8cfd1deea68
|
@@ -55,7 +55,7 @@ module FunWithJsonApi
|
|
55
55
|
|
56
56
|
def check_resource_is_authorized!(resource, id_value)
|
57
57
|
SchemaValidators::CheckResourceIsAuthorised.call(
|
58
|
-
resource, id_value, deserializer,
|
58
|
+
resource, id_value, deserializer, resource_pointer: "/data/relationships/#{name}"
|
59
59
|
)
|
60
60
|
end
|
61
61
|
|
@@ -79,7 +79,7 @@ module FunWithJsonApi
|
|
79
79
|
def build_missing_relationship_error(id_value, message = nil)
|
80
80
|
message ||= missing_resource_debug_message(id_value)
|
81
81
|
payload = ExceptionPayload.new
|
82
|
-
payload.pointer = "/data/relationships/#{name}
|
82
|
+
payload.pointer = "/data/relationships/#{name}"
|
83
83
|
payload.detail = "Unable to find '#{deserializer.type}' with matching id"\
|
84
84
|
": #{id_value.inspect}"
|
85
85
|
Exceptions::MissingRelationship.new(message, payload)
|
@@ -120,7 +120,7 @@ module FunWithJsonApi
|
|
120
120
|
next if collection_ids.include?(resource_id)
|
121
121
|
|
122
122
|
ExceptionPayload.new.tap do |payload|
|
123
|
-
payload.pointer = "/data/relationships/#{name}/data/#{index}
|
123
|
+
payload.pointer = "/data/relationships/#{name}/data/#{index}"
|
124
124
|
payload.detail = "Unable to find '#{deserializer.type}' with matching id"\
|
125
125
|
": \"#{resource_id}\""
|
126
126
|
end
|
@@ -144,7 +144,7 @@ module FunWithJsonApi
|
|
144
144
|
def build_invalid_resource_exception_payload(failed_resources_hash, failure_message_or_callable)
|
145
145
|
failed_resources_hash.map do |index, resource|
|
146
146
|
failure_message = failure_message_for_resource(resource, failure_message_or_callable)
|
147
|
-
ExceptionPayload.new(detail: failure_message, pointer: "/data/#{index}
|
147
|
+
ExceptionPayload.new(detail: failure_message, pointer: "/data/#{index}")
|
148
148
|
end
|
149
149
|
end
|
150
150
|
end
|
@@ -87,7 +87,7 @@ module FunWithJsonApi
|
|
87
87
|
message = "#{deserializer_name} was unable to find resource by '#{deserializer.id_param}'"\
|
88
88
|
": '#{document_id}'"
|
89
89
|
payload = ExceptionPayload.new
|
90
|
-
payload.pointer = '/data
|
90
|
+
payload.pointer = '/data'
|
91
91
|
payload.detail = missing_resource_message
|
92
92
|
Exceptions::MissingResource.new(message, payload)
|
93
93
|
end
|
@@ -48,7 +48,7 @@ module FunWithJsonApi
|
|
48
48
|
def build_missing_resource_payload(collection_ids, resource_id, index)
|
49
49
|
unless collection_ids.include?(resource_id)
|
50
50
|
ExceptionPayload.new(
|
51
|
-
pointer: "#{prefix}/#{index}
|
51
|
+
pointer: "#{prefix}/#{index}",
|
52
52
|
detail: missing_resource_message(resource_id)
|
53
53
|
)
|
54
54
|
end
|
@@ -44,7 +44,7 @@ module FunWithJsonApi
|
|
44
44
|
def build_unauthorized_resource_payload(resource, index)
|
45
45
|
unless deserializer.resource_authorizer.call(resource)
|
46
46
|
ExceptionPayload.new(
|
47
|
-
pointer: "#{prefix}/#{index}
|
47
|
+
pointer: "#{prefix}/#{index}",
|
48
48
|
detail: unauthorized_resource_message(collection_ids[index])
|
49
49
|
)
|
50
50
|
end
|
@@ -10,13 +10,13 @@ module FunWithJsonApi
|
|
10
10
|
attr_reader :resource
|
11
11
|
attr_reader :resource_id
|
12
12
|
attr_reader :deserializer
|
13
|
-
attr_reader :
|
13
|
+
attr_reader :resource_pointer
|
14
14
|
|
15
|
-
def initialize(resource, resource_id, deserializer,
|
15
|
+
def initialize(resource, resource_id, deserializer, resource_pointer: '/data')
|
16
16
|
@resource = resource
|
17
17
|
@resource_id = resource_id
|
18
18
|
@deserializer = deserializer
|
19
|
-
@
|
19
|
+
@resource_pointer = resource_pointer
|
20
20
|
end
|
21
21
|
|
22
22
|
def call
|
@@ -24,7 +24,7 @@ module FunWithJsonApi
|
|
24
24
|
raise Exceptions::UnauthorisedResource.new(
|
25
25
|
"resource_authorizer method for '#{deserializer.type}' returned a false value",
|
26
26
|
ExceptionPayload.new(
|
27
|
-
pointer:
|
27
|
+
pointer: resource_pointer,
|
28
28
|
detail: unauthorized_resource_message
|
29
29
|
)
|
30
30
|
)
|