jsonapi_compliable 0.10.7 → 0.10.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +0 -5
- data/lib/generators/jsonapi/templates/destroy_request_spec.rb.erb +1 -1
- data/lib/generators/jsonapi/templates/index_request_spec.rb.erb +1 -1
- data/lib/generators/jsonapi/templates/show_request_spec.rb.erb +1 -1
- data/lib/jsonapi_compliable/adapters/active_record.rb +2 -0
- data/lib/jsonapi_compliable/errors.rb +11 -0
- data/lib/jsonapi_compliable/scope.rb +5 -0
- data/lib/jsonapi_compliable/version.rb +1 -1
- 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: c57344ec75f9fa96fd13ebcf83abe1ca58d1d20e
|
4
|
+
data.tar.gz: cf942fd528a49bbad613692b4d6db297742c8224
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 07dbfa3e4559cc419343479ed870d9264e66b6a6c9c34eac5384b49e2259ac1ecd8d12cbd098fa03dbcb34b5269617fd20fa598e1fb797be62d7a1ab0a89ce2e
|
7
|
+
data.tar.gz: 3ade1417f03913ad2df35d6447a19c15fe4eb302e3effe1c00b9822fc376accb8d482e20dcbaaaa366204f5c44bdc82968f469d4bd8db79029a6165ed78e6f85
|
data/.travis.yml
CHANGED
@@ -2,7 +2,7 @@ require 'rails_helper'
|
|
2
2
|
|
3
3
|
RSpec.describe "<%= type %>#destroy", type: :request do
|
4
4
|
context 'basic destroy' do
|
5
|
-
let!(:<%= file_name %>) {
|
5
|
+
let!(:<%= file_name %>) { create(:<%= file_name %>) }
|
6
6
|
|
7
7
|
it 'updates the resource' do
|
8
8
|
expect {
|
@@ -6,7 +6,7 @@ RSpec.describe "<%= file_name.pluralize %>#index", type: :request do
|
|
6
6
|
let!(:<%= file_name %>2) { create(:<%= file_name %>) }
|
7
7
|
|
8
8
|
it 'serializes the list correctly' do
|
9
|
-
|
9
|
+
jsonapi_get "/<%= api_namespace %>/v1/<%= file_name.pluralize %>"
|
10
10
|
|
11
11
|
expect(json_ids(true)).to match_array([<%= file_name %>1.id, <%= file_name %>2.id])
|
12
12
|
assert_payload(:<%= file_name %>, <%= file_name %>1, json_items[0])
|
@@ -5,7 +5,7 @@ RSpec.describe "<%= file_name.pluralize %>#show", type: :request do
|
|
5
5
|
let!(:<%= file_name %>) { create(:<%= file_name %>) }
|
6
6
|
|
7
7
|
it 'serializes the resource correctly' do
|
8
|
-
|
8
|
+
jsonapi_get "/<%= api_namespace %>/v1/<%= file_name.pluralize %>/#{<%= file_name %>.id}"
|
9
9
|
|
10
10
|
assert_payload(:<%= file_name %>, <%= file_name %>, json_item)
|
11
11
|
end
|
@@ -13,6 +13,17 @@ module JsonapiCompliable
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
+
class InvalidInclude < StandardError
|
17
|
+
def initialize(relationship, parent_resource)
|
18
|
+
@relationship = relationship
|
19
|
+
@parent_resource = parent_resource
|
20
|
+
end
|
21
|
+
|
22
|
+
def message
|
23
|
+
"The requested included relationship \"#{@relationship}\" is not supported on resource \"#{@parent_resource}\""
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
16
27
|
class StatNotFound < StandardError
|
17
28
|
def initialize(attribute, calculation)
|
18
29
|
@attribute = attribute
|
@@ -81,6 +81,11 @@ module JsonapiCompliable
|
|
81
81
|
|
82
82
|
includes.each_pair do |name, nested|
|
83
83
|
sideload = @resource.sideload(name)
|
84
|
+
|
85
|
+
unless sideload
|
86
|
+
raise JsonapiCompliable::Errors::InvalidInclude.new(name, @resource.type)
|
87
|
+
end
|
88
|
+
|
84
89
|
namespace = Util::Sideload.namespace(@namespace, sideload.name)
|
85
90
|
sideload.resolve(results, @query, namespace)
|
86
91
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jsonapi_compliable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
4
|
+
version: 0.10.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lee Richmond
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2018-01-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: jsonapi-serializable
|