File tree 1 file changed +46
-8
lines changed
1 file changed +46
-8
lines changed Original file line number Diff line number Diff line change 35
35
end
36
36
end
37
37
38
- context 'when payload is valid' do
39
- let ( :post_record ) do
40
- double \
41
- id : 1 ,
42
- title : 'post title' ,
43
- description : 'post description' ,
44
- views : 100
45
- end
38
+ let ( :post_record ) do
39
+ double \
40
+ id : 1 ,
41
+ title : 'post title' ,
42
+ description : 'post description' ,
43
+ views : 100
44
+ end
46
45
46
+ context 'when payload is valid' do
47
47
it 'passes assertion' do
48
48
assert_payload ( :post , post_record , json_item )
49
49
end
235
235
end
236
236
end
237
237
end
238
+
239
+ context 'when payload contains a "relationship-only" item' do
240
+ before do
241
+ JsonapiSpecHelpers ::Payload . register ( :no_attribute_item ) do
242
+ end
243
+ end
244
+
245
+ let ( :no_attribute_record ) do
246
+ double \
247
+ id : 1 ,
248
+ posts : post_record
249
+ end
250
+
251
+ let ( :json ) do
252
+ {
253
+ 'data' => {
254
+ 'type' => 'no_attributes_items' ,
255
+ 'id' => '1' ,
256
+ 'relationships' => {
257
+ 'posts' => {
258
+ 'data' => [
259
+ { 'type' => 'posts' , 'id' => '1' }
260
+ ]
261
+ }
262
+ }
263
+ }
264
+ }
265
+ end
266
+
267
+ it 'still properly throws when no item is present' do
268
+ empty_json_item = { 'id' => nil , 'jsonapi_type' => nil }
269
+ expect {
270
+ assert_payload ( :no_attribute_item , no_attribute_record , empty_json_item )
271
+ } . to raise_error (
272
+ RSpec ::Expectations ::ExpectationNotMetError
273
+ )
274
+ end
275
+ end
238
276
end
239
277
end
You can’t perform that action at this time.
0 commit comments