fun_with_json_api 0.0.10.1 → 0.0.10.2
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/config/locales/fun_with_json_api.en.yml +3 -2
- data/lib/fun_with_json_api/exceptions/unauthorized_relationship.rb +17 -0
- data/lib/fun_with_json_api/schema_validators/check_relationship_names.rb +29 -19
- data/lib/fun_with_json_api/version.rb +1 -1
- data/spec/dummy/log/test.log +9898 -0
- data/spec/fun_with_json_api/find_collection_from_document_spec.rb +2 -2
- data/spec/fun_with_json_api/find_resource_from_document_spec.rb +1 -1
- data/spec/fun_with_json_api/schema_validators/check_relationships_spec.rb +6 -6
- metadata +2 -1
@@ -31,7 +31,7 @@ describe FunWithJsonApi::FindCollectionFromDocument do
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
-
context 'when the resource is
|
34
|
+
context 'when the resource is unauthorized' do
|
35
35
|
before do
|
36
36
|
resource_authorizer = double(:resource_authorizer)
|
37
37
|
allow(resource_authorizer).to receive(:call).with(resource).and_return(false)
|
@@ -121,7 +121,7 @@ describe FunWithJsonApi::FindCollectionFromDocument do
|
|
121
121
|
end
|
122
122
|
end
|
123
123
|
|
124
|
-
context 'when there are
|
124
|
+
context 'when there are unauthorized resources' do
|
125
125
|
before do
|
126
126
|
resource_authorizer = double(:resource_authorizer)
|
127
127
|
allow(resource_authorizer).to receive(:call).and_return(false)
|
@@ -31,7 +31,7 @@ describe FunWithJsonApi::FindResourceFromDocument do
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
-
context 'when the resource is
|
34
|
+
context 'when the resource is unauthorized' do
|
35
35
|
before do
|
36
36
|
resource_authorizer = double(:resource_authorizer)
|
37
37
|
allow(resource_authorizer).to receive(:call).with(resource).and_return(false)
|
@@ -150,18 +150,18 @@ describe FunWithJsonApi::SchemaValidators::CheckRelationships do
|
|
150
150
|
allow(deserializer).to receive(:relationships).and_return([])
|
151
151
|
end
|
152
152
|
|
153
|
-
it 'raises a
|
153
|
+
it 'raises a UnauthorizedRelationship error' do
|
154
154
|
expect do
|
155
155
|
subject
|
156
|
-
end.to raise_error(FunWithJsonApi::Exceptions::
|
157
|
-
|
156
|
+
end.to raise_error(FunWithJsonApi::Exceptions::UnauthorizedRelationship) do |e|
|
157
|
+
expect(e.http_status).to eq 403
|
158
158
|
expect(e.payload.size).to eq 1
|
159
159
|
|
160
160
|
payload = e.payload.first
|
161
|
-
expect(payload.code).to eq '
|
161
|
+
expect(payload.code).to eq 'unauthorized_relationship'
|
162
162
|
expect(payload.pointer).to eq '/data/relationships/foobar'
|
163
163
|
expect(payload.title).to eq(
|
164
|
-
'Request json_api relationship
|
164
|
+
'Request json_api relationship can not be updated by the current endpoint'
|
165
165
|
)
|
166
166
|
expect(payload.detail).to eq(
|
167
167
|
"The provided relationship 'foobar' can not be assigned to a 'examples' resource"\
|
@@ -197,7 +197,7 @@ describe FunWithJsonApi::SchemaValidators::CheckRelationships do
|
|
197
197
|
)
|
198
198
|
expect(payload.detail).to eq(
|
199
199
|
"The provided relationship 'foobar' can not be directly assigned to a 'examples'"\
|
200
|
-
' resource'
|
200
|
+
' resource, or is an unknown relationship'
|
201
201
|
)
|
202
202
|
expect(payload.status).to eq '400'
|
203
203
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fun_with_json_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.10.
|
4
|
+
version: 0.0.10.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Morrall
|
@@ -181,6 +181,7 @@ files:
|
|
181
181
|
- lib/fun_with_json_api/exceptions/missing_relationship.rb
|
182
182
|
- lib/fun_with_json_api/exceptions/missing_resource.rb
|
183
183
|
- lib/fun_with_json_api/exceptions/relationship_method_not_supported.rb
|
184
|
+
- lib/fun_with_json_api/exceptions/unauthorized_relationship.rb
|
184
185
|
- lib/fun_with_json_api/exceptions/unauthorized_resource.rb
|
185
186
|
- lib/fun_with_json_api/exceptions/unknown_attribute.rb
|
186
187
|
- lib/fun_with_json_api/exceptions/unknown_relationship.rb
|