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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f7f3fde1d93829c0cae1e4a182d93fb179480ebe
4
- data.tar.gz: 617a21bae42b814b68d59205da139504436549fb
3
+ metadata.gz: c57344ec75f9fa96fd13ebcf83abe1ca58d1d20e
4
+ data.tar.gz: cf942fd528a49bbad613692b4d6db297742c8224
5
5
  SHA512:
6
- metadata.gz: aa0f523a1ab819795655ae3fa18961b883f790432de523582ad9113737bc79f48d76082fc76895fbcccff0c0b5a7ecdd6051c3bb0c87aab5550ae46ad55ff707
7
- data.tar.gz: 410d64165adb71abf7925194247e7931e27d5f216b2dbd47491ff2f02827c936294cd7c22c8226e81316b85d8eddef503bbac6fd8866992ebc0c9b3437b8539c
6
+ metadata.gz: 07dbfa3e4559cc419343479ed870d9264e66b6a6c9c34eac5384b49e2259ac1ecd8d12cbd098fa03dbcb34b5269617fd20fa598e1fb797be62d7a1ab0a89ce2e
7
+ data.tar.gz: 3ade1417f03913ad2df35d6447a19c15fe4eb302e3effe1c00b9822fc376accb8d482e20dcbaaaa366204f5c44bdc82968f469d4bd8db79029a6165ed78e6f85
data/.travis.yml CHANGED
@@ -5,11 +5,6 @@ rvm:
5
5
 
6
6
  script: "bundle exec rake"
7
7
 
8
- before_install:
9
- - gem update --system
10
- - rvm @global do gem uninstall bundler -a -x
11
- - rvm @global do gem install bundler -v 1.14.6
12
-
13
8
  install: bundle install --retry=3 --jobs=3
14
9
 
15
10
  gemfile:
@@ -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 %>) { FactoryGirl.create(:<%= 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
- get "/<%= api_namespace %>/v1/<%= file_name.pluralize %>"
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
- get "/<%= api_namespace %>/v1/<%= file_name.pluralize %>/#{<%= file_name %>.id}"
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
@@ -80,6 +80,8 @@ module JsonapiCompliable
80
80
  else
81
81
  parent.send(association_name) << child
82
82
  end
83
+ elsif association_type == :has_one
84
+ parent.send("#{association_name}=", child)
83
85
  elsif
84
86
  child.send("#{association_name}=", parent)
85
87
  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
@@ -1,3 +1,3 @@
1
1
  module JsonapiCompliable
2
- VERSION = "0.10.7"
2
+ VERSION = "0.10.9"
3
3
  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.7
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: 2017-10-23 00:00:00.000000000 Z
12
+ date: 2018-01-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: jsonapi-serializable