jsonapi-resources 0.4.4 → 0.5.0

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.
@@ -70,7 +70,7 @@ class JSONAPIRequestTest < ActiveSupport::TestCase
70
70
  )
71
71
 
72
72
  refute request.errors.empty?
73
- assert_equal 'iso_currency is not a valid association of expense-entries', request.errors[0].detail
73
+ assert_equal 'iso_currency is not a valid relationship of expense-entries', request.errors[0].detail
74
74
  end
75
75
 
76
76
  def test_parse_fields_underscored
@@ -99,7 +99,7 @@ class OperationsProcessorTest < Minitest::Test
99
99
  assert_equal(Planet.count, count + 3)
100
100
  end
101
101
 
102
- def test_replace_has_one_association
102
+ def test_replace_to_one_relationship
103
103
  op = JSONAPI::OperationsProcessor.new()
104
104
 
105
105
  saturn = Planet.find(1)
@@ -108,11 +108,11 @@ class OperationsProcessorTest < Minitest::Test
108
108
  assert_equal(saturn.planet_type_id, planetoid.id)
109
109
 
110
110
  operations = [
111
- JSONAPI::ReplaceHasOneAssociationOperation.new(
111
+ JSONAPI::ReplaceToOneRelationshipOperation.new(
112
112
  PlanetResource,
113
113
  {
114
114
  resource_id: saturn.id,
115
- association_type: :planet_type,
115
+ relationship_type: :planet_type,
116
116
  key_value: gas_giant.id
117
117
  }
118
118
  )
@@ -132,11 +132,11 @@ class OperationsProcessorTest < Minitest::Test
132
132
 
133
133
  # Remove link
134
134
  operations = [
135
- JSONAPI::ReplaceHasOneAssociationOperation.new(
135
+ JSONAPI::ReplaceToOneRelationshipOperation.new(
136
136
  PlanetResource,
137
137
  {
138
138
  resource_id: saturn.id,
139
- association_type: :planet_type,
139
+ relationship_type: :planet_type,
140
140
  key_value: nil
141
141
  }
142
142
  )
@@ -151,11 +151,11 @@ class OperationsProcessorTest < Minitest::Test
151
151
 
152
152
  # Reset
153
153
  operations = [
154
- JSONAPI::ReplaceHasOneAssociationOperation.new(
154
+ JSONAPI::ReplaceToOneRelationshipOperation.new(
155
155
  PlanetResource,
156
156
  {
157
157
  resource_id: saturn.id,
158
- association_type: :planet_type,
158
+ relationship_type: :planet_type,
159
159
  key_value: 5
160
160
  }
161
161
  )
@@ -169,7 +169,7 @@ class OperationsProcessorTest < Minitest::Test
169
169
  assert_equal(saturn.planet_type_id, 5)
170
170
  end
171
171
 
172
- def test_create_has_many_association
172
+ def test_create_to_many_relationship
173
173
  op = JSONAPI::OperationsProcessor.new()
174
174
 
175
175
  betax = Planet.find(5)
@@ -185,11 +185,11 @@ class OperationsProcessorTest < Minitest::Test
185
185
  betaz.save!
186
186
 
187
187
  operations = [
188
- JSONAPI::CreateHasManyAssociationOperation.new(
188
+ JSONAPI::CreateToManyRelationshipOperation.new(
189
189
  PlanetTypeResource,
190
190
  {
191
191
  resource_id: gas_giant.id,
192
- association_type: :planets,
192
+ relationship_type: :planets,
193
193
  data: [betax.id, betay.id, betaz.id]
194
194
  }
195
195
  )
@@ -217,7 +217,7 @@ class OperationsProcessorTest < Minitest::Test
217
217
  betaz.save!
218
218
  end
219
219
 
220
- def test_replace_has_many_association
220
+ def test_replace_to_many_relationship
221
221
  op = JSONAPI::OperationsProcessor.new()
222
222
 
223
223
  betax = Planet.find(5)
@@ -233,11 +233,11 @@ class OperationsProcessorTest < Minitest::Test
233
233
  betaz.save!
234
234
 
235
235
  operations = [
236
- JSONAPI::ReplaceHasManyAssociationOperation.new(
236
+ JSONAPI::ReplaceToManyRelationshipOperation.new(
237
237
  PlanetTypeResource,
238
238
  {
239
239
  resource_id: gas_giant.id,
240
- association_type: :planets,
240
+ relationship_type: :planets,
241
241
  data: [betax.id, betay.id, betaz.id]
242
242
  }
243
243
  )
@@ -386,11 +386,11 @@ class OperationsProcessorTest < Minitest::Test
386
386
  assert operation_results.has_errors?
387
387
  end
388
388
 
389
- def test_show_association_operation
389
+ def test_show_relationship_operation
390
390
  op = JSONAPI::OperationsProcessor.new
391
391
 
392
392
  operations = [
393
- JSONAPI::ShowAssociationOperation.new(PlanetResource, {parent_key: '1', association_type: :planet_type})
393
+ JSONAPI::ShowRelationshipOperation.new(PlanetResource, {parent_key: '1', relationship_type: :planet_type})
394
394
  ]
395
395
 
396
396
  request = JSONAPI::Request.new
@@ -403,11 +403,11 @@ class OperationsProcessorTest < Minitest::Test
403
403
  refute operation_results.has_errors?
404
404
  end
405
405
 
406
- def test_show_association_operation_error
406
+ def test_show_relationship_operation_error
407
407
  op = JSONAPI::OperationsProcessor.new
408
408
 
409
409
  operations = [
410
- JSONAPI::ShowAssociationOperation.new(PlanetResource, {parent_key: '145', association_type: :planet_type})
410
+ JSONAPI::ShowRelationshipOperation.new(PlanetResource, {parent_key: '145', relationship_type: :planet_type})
411
411
  ]
412
412
 
413
413
  request = JSONAPI::Request.new
@@ -428,7 +428,7 @@ class OperationsProcessorTest < Minitest::Test
428
428
  {
429
429
  source_klass: PlanetResource,
430
430
  source_id: '1',
431
- association_type: :planet_type})
431
+ relationship_type: :planet_type})
432
432
  ]
433
433
 
434
434
  request = JSONAPI::Request.new
@@ -449,7 +449,7 @@ class OperationsProcessorTest < Minitest::Test
449
449
  {
450
450
  source_klass: PlanetResource,
451
451
  source_id: '145',
452
- association_type: :planet_type})
452
+ relationship_type: :planet_type})
453
453
  ]
454
454
 
455
455
  request = JSONAPI::Request.new
@@ -470,7 +470,7 @@ class OperationsProcessorTest < Minitest::Test
470
470
  {
471
471
  source_klass: PlanetResource,
472
472
  source_id: '1',
473
- association_type: :moons})
473
+ relationship_type: :moons})
474
474
  ]
475
475
 
476
476
  request = JSONAPI::Request.new
@@ -491,7 +491,7 @@ class OperationsProcessorTest < Minitest::Test
491
491
  {
492
492
  source_klass: PlanetResource,
493
493
  source_id: '145',
494
- association_type: :moons})
494
+ relationship_type: :moons})
495
495
  ]
496
496
 
497
497
  request = JSONAPI::Request.new
@@ -18,7 +18,7 @@ class CatResource < JSONAPI::Resource
18
18
  end
19
19
 
20
20
  class PersonWithCustomRecordsForResource < PersonResource
21
- def records_for(association_name, context)
21
+ def records_for(relationship_name, context)
22
22
  :records_for
23
23
  end
24
24
  end
@@ -34,7 +34,7 @@ end
34
34
 
35
35
  class PersonWithCustomRecordsForErrorResource < PersonResource
36
36
  class AuthorizationError < StandardError; end
37
- def records_for(association_name, context)
37
+ def records_for(relationship_name, context)
38
38
  raise AuthorizationError
39
39
  end
40
40
  end
@@ -62,10 +62,10 @@ class ResourceTest < ActiveSupport::TestCase
62
62
  assert_equal(attrs.keys.size, 3)
63
63
  end
64
64
 
65
- def test_class_associations
66
- associations = CatResource._associations
67
- assert_kind_of(Hash, associations)
68
- assert_equal(associations.size, 2)
65
+ def test_class_relationships
66
+ relationships = CatResource._relationships
67
+ assert_kind_of(Hash, relationships)
68
+ assert_equal(relationships.size, 2)
69
69
  end
70
70
 
71
71
  def test_find_with_customized_base_records
@@ -93,28 +93,28 @@ class ResourceTest < ActiveSupport::TestCase
93
93
  end
94
94
  end
95
95
 
96
- def test_records_for_meta_method_for_has_one
96
+ def test_records_for_meta_method_for_to_one
97
97
  author = Person.find(1)
98
98
  author.update! preferences: Preferences.first
99
99
  author_resource = PersonWithCustomRecordsForRelationshipsResource.new(author)
100
100
  assert_equal(author_resource.record_for_preferences, :record_for_preferences)
101
101
  end
102
102
 
103
- def test_records_for_meta_method_for_has_one_calling_records_for
103
+ def test_records_for_meta_method_for_to_one_calling_records_for
104
104
  author = Person.find(1)
105
105
  author.update! preferences: Preferences.first
106
106
  author_resource = PersonWithCustomRecordsForResource.new(author)
107
107
  assert_equal(author_resource.record_for_preferences, :records_for)
108
108
  end
109
109
 
110
- def test_associated_records_meta_method_for_has_many
110
+ def test_associated_records_meta_method_for_to_many
111
111
  author = Person.find(1)
112
112
  author.posts << Post.find(1)
113
113
  author_resource = PersonWithCustomRecordsForRelationshipsResource.new(author)
114
114
  assert_equal(author_resource.records_for_posts, :records_for_posts)
115
115
  end
116
116
 
117
- def test_associated_records_meta_method_for_has_many_calling_records_for
117
+ def test_associated_records_meta_method_for_to_many_calling_records_for
118
118
  author = Person.find(1)
119
119
  author.posts << Post.find(1)
120
120
  author_resource = PersonWithCustomRecordsForResource.new(author)
@@ -150,7 +150,7 @@ class ResourceTest < ActiveSupport::TestCase
150
150
  end
151
151
  end
152
152
 
153
- def test_has_many_association_filters
153
+ def test_to_many_relationship_filters
154
154
  post_resource = PostResource.new(Post.find(1))
155
155
  comments = post_resource.comments
156
156
  assert_equal(2, comments.size)
@@ -177,7 +177,7 @@ class ResourceTest < ActiveSupport::TestCase
177
177
  end
178
178
  end
179
179
 
180
- def test_has_many_association_sorts
180
+ def test_to_many_relationship_sorts
181
181
  post_resource = PostResource.new(Post.find(1))
182
182
  comment_ids = post_resource.comments.map{|c| c.model.id }
183
183
  assert_equal [1,2], comment_ids
@@ -204,7 +204,7 @@ class ResourceTest < ActiveSupport::TestCase
204
204
  end
205
205
  end
206
206
 
207
- def test_has_many_association_pagination
207
+ def test_to_many_relationship_pagination
208
208
  post_resource = PostResource.new(Post.find(1))
209
209
  comments = post_resource.comments
210
210
  assert_equal 2, comments.size
@@ -0,0 +1,183 @@
1
+ require File.expand_path('../../../test_helper', __FILE__)
2
+ require 'jsonapi-resources'
3
+ require 'json'
4
+
5
+ class LinkBuilderTest < ActionDispatch::IntegrationTest
6
+ def setup
7
+ @base_url = "http://example.com"
8
+ @route_formatter = JSONAPI.configuration.route_formatter
9
+ @steve = Person.create(name: "Steve Rogers", date_joined: "1941-03-01")
10
+ end
11
+
12
+ def test_engine_boolean
13
+ assert JSONAPI::LinkBuilder.new(
14
+ primary_resource_klass: MyEngine::Api::V1::PersonResource
15
+ ).engine?, "MyEngine should be considered an Engine"
16
+
17
+ refute JSONAPI::LinkBuilder.new(
18
+ primary_resource_klass: Api::V1::PersonResource
19
+ ).engine?, "Api shouldn't be considered an Engine"
20
+ end
21
+
22
+ def test_engine_name
23
+ assert_equal MyEngine::Engine,
24
+ JSONAPI::LinkBuilder.new(
25
+ primary_resource_klass: MyEngine::Api::V1::PersonResource
26
+ ).engine_name
27
+
28
+ assert_equal nil,
29
+ JSONAPI::LinkBuilder.new(
30
+ primary_resource_klass: Api::V1::PersonResource
31
+ ).engine_name
32
+ end
33
+
34
+ def test_self_link_regular_app
35
+ primary_resource_klass = Api::V1::PersonResource
36
+
37
+ config = {
38
+ base_url: @base_url,
39
+ route_formatter: @route_formatter,
40
+ primary_resource_klass: primary_resource_klass,
41
+ }
42
+
43
+ builder = JSONAPI::LinkBuilder.new(config)
44
+ source = primary_resource_klass.new(@steve)
45
+ expected_link = "#{ @base_url }/api/v1/people/#{ source.id }"
46
+
47
+ assert_equal expected_link, builder.self_link(source)
48
+ end
49
+
50
+ def test_self_link_with_engine_app
51
+ primary_resource_klass = MyEngine::Api::V1::PersonResource
52
+
53
+ config = {
54
+ base_url: @base_url,
55
+ route_formatter: @route_formatter,
56
+ primary_resource_klass: primary_resource_klass,
57
+ }
58
+
59
+ builder = JSONAPI::LinkBuilder.new(config)
60
+ source = primary_resource_klass.new(@steve)
61
+ expected_link = "#{ @base_url }/boomshaka/api/v1/people/#{ source.id }"
62
+
63
+ assert_equal expected_link, builder.self_link(source)
64
+ end
65
+
66
+ def test_primary_resources_url_for_regular_app
67
+ config = {
68
+ base_url: @base_url,
69
+ route_formatter: @route_formatter,
70
+ primary_resource_klass: Api::V1::PersonResource,
71
+ }
72
+
73
+ builder = JSONAPI::LinkBuilder.new(config)
74
+ expected_link = "#{ @base_url }/api/v1/people"
75
+
76
+ assert_equal expected_link, builder.primary_resources_url
77
+ end
78
+
79
+ def test_primary_resources_url_for_engine
80
+ config = {
81
+ base_url: @base_url,
82
+ route_formatter: @route_formatter,
83
+ primary_resource_klass: MyEngine::Api::V1::PersonResource
84
+ }
85
+
86
+ builder = JSONAPI::LinkBuilder.new(config)
87
+ expected_link = "#{ @base_url }/boomshaka/api/v1/people"
88
+
89
+ assert_equal expected_link, builder.primary_resources_url
90
+ end
91
+
92
+ def test_relationships_self_link_for_regular_app
93
+ config = {
94
+ base_url: @base_url,
95
+ route_formatter: @route_formatter,
96
+ primary_resource_klass: Api::V1::PersonResource
97
+ }
98
+
99
+ builder = JSONAPI::LinkBuilder.new(config)
100
+ source = Api::V1::PersonResource.new(@steve)
101
+ relationship = JSONAPI::Relationship::ToMany.new("posts", {})
102
+ expected_link = "#{ @base_url }/api/v1/people/#{ @steve.id }/relationships/posts"
103
+
104
+ assert_equal expected_link,
105
+ builder.relationships_self_link(source, relationship)
106
+ end
107
+
108
+ def test_relationships_self_link_for_engine
109
+ config = {
110
+ base_url: @base_url,
111
+ route_formatter: @route_formatter,
112
+ primary_resource_klass: MyEngine::Api::V1::PersonResource
113
+ }
114
+
115
+ builder = JSONAPI::LinkBuilder.new(config)
116
+ source = MyEngine::Api::V1::PersonResource.new(@steve)
117
+ relationship = JSONAPI::Relationship::ToMany.new("posts", {})
118
+ expected_link = "#{ @base_url }/boomshaka/api/v1/people/#{ @steve.id }/relationships/posts"
119
+
120
+ assert_equal expected_link,
121
+ builder.relationships_self_link(source, relationship)
122
+ end
123
+
124
+ def test_relationships_related_link_for_regular_app
125
+ config = {
126
+ base_url: @base_url,
127
+ route_formatter: @route_formatter,
128
+ primary_resource_klass: Api::V1::PersonResource
129
+ }
130
+
131
+ builder = JSONAPI::LinkBuilder.new(config)
132
+ source = Api::V1::PersonResource.new(@steve)
133
+ relationship = JSONAPI::Relationship::ToMany.new("posts", {})
134
+ expected_link = "#{ @base_url }/api/v1/people/#{ @steve.id }/posts"
135
+
136
+ assert_equal expected_link,
137
+ builder.relationships_related_link(source, relationship)
138
+ end
139
+
140
+ def test_relationships_related_link_for_engine
141
+ config = {
142
+ base_url: @base_url,
143
+ route_formatter: @route_formatter,
144
+ primary_resource_klass: MyEngine::Api::V1::PersonResource
145
+ }
146
+
147
+ builder = JSONAPI::LinkBuilder.new(config)
148
+ source = MyEngine::Api::V1::PersonResource.new(@steve)
149
+ relationship = JSONAPI::Relationship::ToMany.new("posts", {})
150
+ expected_link = "#{ @base_url }/boomshaka/api/v1/people/#{ @steve.id }/posts"
151
+
152
+ assert_equal expected_link,
153
+ builder.relationships_related_link(source, relationship)
154
+ end
155
+
156
+ def test_query_link_for_regular_app
157
+ config = {
158
+ base_url: @base_url,
159
+ route_formatter: @route_formatter,
160
+ primary_resource_klass: Api::V1::PersonResource
161
+ }
162
+
163
+ query = { page: { offset: 0, limit: 12 } }
164
+ builder = JSONAPI::LinkBuilder.new(config)
165
+ expected_link = "#{ @base_url }/api/v1/people?page%5Blimit%5D=12&page%5Boffset%5D=0"
166
+
167
+ assert_equal expected_link, builder.query_link(query)
168
+ end
169
+
170
+ def test_query_link_for_engine
171
+ config = {
172
+ base_url: @base_url,
173
+ route_formatter: @route_formatter,
174
+ primary_resource_klass: MyEngine::Api::V1::PersonResource
175
+ }
176
+
177
+ query = { page: { offset: 0, limit: 12 } }
178
+ builder = JSONAPI::LinkBuilder.new(config)
179
+ expected_link = "#{ @base_url }/boomshaka/api/v1/people?page%5Blimit%5D=12&page%5Boffset%5D=0"
180
+
181
+ assert_equal expected_link, builder.query_link(query)
182
+ end
183
+ end
@@ -15,15 +15,15 @@ class PolymorphismTest < ActionDispatch::IntegrationTest
15
15
  JSONAPI.configuration.json_key_format = :underscored_key
16
16
  end
17
17
 
18
- def test_polymorphic_association
19
- associations = PictureResource._associations
20
- imageable = associations[:imageable]
18
+ def test_polymorphic_relationship
19
+ relationships = PictureResource._relationships
20
+ imageable = relationships[:imageable]
21
21
 
22
- assert_equal associations.size, 1
22
+ assert_equal relationships.size, 1
23
23
  assert imageable.polymorphic?
24
24
  end
25
25
 
26
- def test_polymorphic_has_many_serialization
26
+ def test_sti_polymorphic_to_many_serialization
27
27
  serialized_data = JSONAPI::ResourceSerializer.new(
28
28
  PersonResource,
29
29
  include: %w(vehicles)
@@ -31,94 +31,93 @@ class PolymorphismTest < ActionDispatch::IntegrationTest
31
31
 
32
32
  assert_hash_equals(
33
33
  {
34
- :data => {
35
- "id" => "1",
36
- "type" => "people",
37
- "links" => {
38
- :self => "/people/1"
34
+ data: {
35
+ id: '1',
36
+ type: 'people',
37
+ links: {
38
+ self: '/people/1'
39
39
  },
40
- "attributes" => {
41
- "name" => "Joe Author",
42
- "email" => "joe@xyz.fake",
43
- "dateJoined" => "2013-08-07 16:25:00 -0400"
40
+ attributes: {
41
+ name: 'Joe Author',
42
+ email: 'joe@xyz.fake',
43
+ dateJoined: '2013-08-07 16:25:00 -0400'
44
44
  },
45
- "relationships" => {
46
- "comments" => {
47
- :links => {
48
- :self => "/people/1/relationships/comments",
49
- :related => "/people/1/comments"
45
+ relationships: {
46
+ comments: {
47
+ links: {
48
+ self: '/people/1/relationships/comments',
49
+ related: '/people/1/comments'
50
50
  }
51
51
  },
52
- "posts" => {
53
- :links => {
54
- :self => "/people/1/relationships/posts",
55
- :related => "/people/1/posts"
52
+ posts: {
53
+ links: {
54
+ self: '/people/1/relationships/posts',
55
+ related: '/people/1/posts'
56
56
  }
57
57
  },
58
- "vehicles" => {
59
- :links => {
60
- :self => "/people/1/relationships/vehicles",
61
- :related => "/people/1/vehicles"
58
+ vehicles: {
59
+ links: {
60
+ self: '/people/1/relationships/vehicles',
61
+ related: '/people/1/vehicles'
62
62
  },
63
63
  :data => [
64
- { :type => "cars", :id=> "1" },
65
- { :type => "boats", :id=>"2" }
64
+ { type: 'cars', id: '1' },
65
+ { type: 'boats', id: '2' }
66
66
  ]
67
67
  },
68
- "preferences" => {
69
- :links => {
70
- :self => "/people/1/relationships/preferences",
71
- :related => "/people/1/preferences"
72
- },
73
- :data => {
74
- :type => "preferences",
75
- :id=>"1"
68
+ preferences: {
69
+ links: {
70
+ self: '/people/1/relationships/preferences',
71
+ related: '/people/1/preferences'
76
72
  }
77
73
  },
78
- "hairCut" => {
79
- :links => {
80
- :self => "/people/1/relationships/hairCut",
81
- :related => "/people/1/hairCut"
82
- },
83
- :data => nil
74
+ hairCut: {
75
+ links: {
76
+ self: '/people/1/relationships/hairCut',
77
+ related: '/people/1/hairCut'
78
+ }
84
79
  }
85
80
  }
86
81
  },
87
- :included => [
82
+ included: [
88
83
  {
89
- "id" => "1",
90
- "type" => "cars",
91
- "links" => {
92
- :self => "/cars/1"
84
+ id: '1',
85
+ type: 'cars',
86
+ links: {
87
+ self: '/cars/1'
93
88
  },
94
- "relationships" => {
95
- "person" => {
96
- :links => {
97
- :self => "/cars/1/relationships/person",
98
- :related => "/cars/1/person"
99
- },
100
- :data => {
101
- :type => "people",
102
- :id => "1"
89
+ attributes: {
90
+ make: 'Mazda',
91
+ vehicleModel: 'Miata MX5',
92
+ driveLayout: 'Front Engine RWD',
93
+ serialNumber: '32432adfsfdysua'
94
+ },
95
+ relationships: {
96
+ person: {
97
+ links: {
98
+ self: '/cars/1/relationships/person',
99
+ related: '/cars/1/person'
103
100
  }
104
101
  }
105
102
  }
106
103
  },
107
104
  {
108
- "id" => "2",
109
- "type" => "boats",
110
- "links" => {
111
- :self => "/boats/2"
105
+ id: '2',
106
+ type: 'boats',
107
+ links: {
108
+ self: '/boats/2'
112
109
  },
113
- "relationships" => {
114
- "person" => {
115
- :links => {
116
- :self => "/boats/2/relationships/person",
117
- :related => "/boats/2/person"
118
- },
119
- :data => {
120
- :type => "people",
121
- :id => "1"
110
+ attributes: {
111
+ make: 'Chris-Craft',
112
+ vehicleModel: 'Launch 20',
113
+ lengthAtWaterLine: '15.5ft',
114
+ serialNumber: '434253JJJSD'
115
+ },
116
+ relationships: {
117
+ person: {
118
+ links: {
119
+ self: '/boats/2/relationships/person',
120
+ related: '/boats/2/person'
122
121
  }
123
122
  }
124
123
  }
@@ -129,7 +128,7 @@ class PolymorphismTest < ActionDispatch::IntegrationTest
129
128
  )
130
129
  end
131
130
 
132
- def test_polymorphic_has_one_serialization
131
+ def test_polymorphic_to_one_serialization
133
132
  serialized_data = JSONAPI::ResourceSerializer.new(
134
133
  PictureResource,
135
134
  include: %w(imageable)
@@ -318,7 +317,7 @@ class PolymorphismTest < ActionDispatch::IntegrationTest
318
317
 
319
318
  patch "/pictures/#{picture.id}/relationships/imageable",
320
319
  {
321
- association: 'imageable',
320
+ relationship: 'imageable',
322
321
  data: {
323
322
  type: 'documents',
324
323
  id: '1'
@@ -343,7 +342,7 @@ class PolymorphismTest < ActionDispatch::IntegrationTest
343
342
 
344
343
  patch "/pictures/#{picture.id}/relationships/imageable",
345
344
  {
346
- association: 'imageable',
345
+ relationship: 'imageable',
347
346
  data: {
348
347
  type: 'documents',
349
348
  id: '1'
@@ -368,7 +367,7 @@ class PolymorphismTest < ActionDispatch::IntegrationTest
368
367
 
369
368
  delete "/pictures/#{picture.id}/relationships/imageable",
370
369
  {
371
- association: 'imageable'
370
+ relationship: 'imageable'
372
371
  }.to_json,
373
372
  {
374
373
  'Content-Type' => JSONAPI::MEDIA_TYPE