jsonapi-resources 0.2.0 → 0.3.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -1
  3. data/.travis.yml +5 -2
  4. data/Gemfile +3 -1
  5. data/README.md +52 -13
  6. data/jsonapi-resources.gemspec +1 -1
  7. data/lib/jsonapi-resources.rb +1 -0
  8. data/lib/jsonapi/association.rb +1 -9
  9. data/lib/jsonapi/error_codes.rb +1 -0
  10. data/lib/jsonapi/exceptions.rb +9 -5
  11. data/lib/jsonapi/formatter.rb +9 -18
  12. data/lib/jsonapi/paginator.rb +4 -15
  13. data/lib/jsonapi/request.rb +26 -42
  14. data/lib/jsonapi/resource.rb +35 -45
  15. data/lib/jsonapi/resource_controller.rb +6 -32
  16. data/lib/jsonapi/resource_serializer.rb +62 -33
  17. data/lib/jsonapi/resources/version.rb +1 -1
  18. data/lib/jsonapi/routing_ext.rb +4 -4
  19. data/test/config/database.yml +2 -1
  20. data/test/controllers/controller_test.rb +200 -160
  21. data/test/fixtures/active_record.rb +44 -201
  22. data/test/fixtures/book_comments.yml +11 -0
  23. data/test/fixtures/books.yml +6 -0
  24. data/test/fixtures/comments.yml +17 -0
  25. data/test/fixtures/comments_tags.yml +20 -0
  26. data/test/fixtures/expense_entries.yml +13 -0
  27. data/test/fixtures/facts.yml +11 -0
  28. data/test/fixtures/iso_currencies.yml +17 -0
  29. data/test/fixtures/people.yml +24 -0
  30. data/test/fixtures/posts.yml +96 -0
  31. data/test/fixtures/posts_tags.yml +59 -0
  32. data/test/fixtures/preferences.yml +18 -0
  33. data/test/fixtures/sections.yml +8 -0
  34. data/test/fixtures/tags.yml +39 -0
  35. data/test/helpers/hash_helpers.rb +0 -7
  36. data/test/integration/requests/request_test.rb +86 -28
  37. data/test/integration/routes/routes_test.rb +14 -25
  38. data/test/test_helper.rb +41 -17
  39. data/test/unit/jsonapi_request/jsonapi_request_test.rb +152 -0
  40. data/test/unit/operation/operations_processor_test.rb +13 -2
  41. data/test/unit/resource/resource_test.rb +68 -13
  42. data/test/unit/serializer/serializer_test.rb +328 -220
  43. metadata +33 -6
  44. data/lib/jsonapi/resource_for.rb +0 -29
@@ -1,9 +1,8 @@
1
1
  require File.expand_path('../../../test_helper', __FILE__)
2
- require File.expand_path('../../../fixtures/active_record', __FILE__)
3
2
  require 'jsonapi-resources'
4
3
  require 'json'
5
4
 
6
- class SerializerTest < MiniTest::Unit::TestCase
5
+ class SerializerTest < ActionDispatch::IntegrationTest
7
6
  def setup
8
7
  @post = Post.find(1)
9
8
  @fred = Person.find_by(name: 'Fred Reader')
@@ -31,23 +30,24 @@ class SerializerTest < MiniTest::Unit::TestCase
31
30
  self: 'http://example.com/posts/1',
32
31
  section: {
33
32
  self: 'http://example.com/posts/1/links/section',
34
- resource: 'http://example.com/posts/1/section',
35
- type: 'sections',
36
- id: nil
33
+ related: 'http://example.com/posts/1/section',
34
+ linkage: { }
37
35
  },
38
36
  author: {
39
37
  self: 'http://example.com/posts/1/links/author',
40
- resource: 'http://example.com/posts/1/author',
41
- type: 'people',
42
- id: '1'
38
+ related: 'http://example.com/posts/1/author',
39
+ linkage: {
40
+ type: 'people',
41
+ id: '1'
42
+ }
43
43
  },
44
44
  tags: {
45
45
  self: 'http://example.com/posts/1/links/tags',
46
- resource: 'http://example.com/posts/1/tags'
46
+ related: 'http://example.com/posts/1/tags'
47
47
  },
48
48
  comments: {
49
49
  self: 'http://example.com/posts/1/links/comments',
50
- resource: 'http://example.com/posts/1/comments'
50
+ related: 'http://example.com/posts/1/comments'
51
51
  }
52
52
  }
53
53
  }
@@ -70,19 +70,21 @@ class SerializerTest < MiniTest::Unit::TestCase
70
70
  self: 'http://example.com/api/v1/posts/1',
71
71
  section: {
72
72
  self: 'http://example.com/api/v1/posts/1/links/section',
73
- resource: 'http://example.com/api/v1/posts/1/section',
74
- type: 'sections',
75
- id: nil
73
+ related: 'http://example.com/api/v1/posts/1/section',
74
+ linkage: {
75
+ }
76
76
  },
77
77
  writer: {
78
78
  self: 'http://example.com/api/v1/posts/1/links/writer',
79
- resource: 'http://example.com/api/v1/posts/1/writer',
80
- type: 'writers',
81
- id: '1'
79
+ related: 'http://example.com/api/v1/posts/1/writer',
80
+ linkage: {
81
+ type: 'writers',
82
+ id: '1'
83
+ }
82
84
  },
83
85
  comments: {
84
86
  self: 'http://example.com/api/v1/posts/1/links/comments',
85
- resource: 'http://example.com/api/v1/posts/1/comments'
87
+ related: 'http://example.com/api/v1/posts/1/comments'
86
88
  }
87
89
  }
88
90
  }
@@ -105,9 +107,11 @@ class SerializerTest < MiniTest::Unit::TestCase
105
107
  self: '/posts/1',
106
108
  author: {
107
109
  self: '/posts/1/links/author',
108
- resource: '/posts/1/author',
109
- type: 'people',
110
- id: '1'
110
+ related: '/posts/1/author',
111
+ linkage: {
112
+ type: 'people',
113
+ id: '1'
114
+ }
111
115
  }
112
116
  }
113
117
  }
@@ -131,27 +135,29 @@ class SerializerTest < MiniTest::Unit::TestCase
131
135
  self: '/posts/1',
132
136
  section: {
133
137
  self: '/posts/1/links/section',
134
- resource: '/posts/1/section',
135
- type: 'sections',
136
- id: nil
138
+ related: '/posts/1/section',
139
+ linkage: {
140
+ }
137
141
  },
138
142
  author: {
139
143
  self: '/posts/1/links/author',
140
- resource: '/posts/1/author',
141
- type: 'people',
142
- id: '1'
144
+ related: '/posts/1/author',
145
+ linkage: {
146
+ type: 'people',
147
+ id: '1'
148
+ }
143
149
  },
144
150
  tags: {
145
151
  self: '/posts/1/links/tags',
146
- resource: '/posts/1/tags'
152
+ related: '/posts/1/tags'
147
153
  },
148
154
  comments: {
149
155
  self: '/posts/1/links/comments',
150
- resource: '/posts/1/comments'
156
+ related: '/posts/1/comments'
151
157
  }
152
158
  }
153
159
  },
154
- linked: [
160
+ included: [
155
161
  {
156
162
  type: 'people',
157
163
  id: '1',
@@ -162,11 +168,19 @@ class SerializerTest < MiniTest::Unit::TestCase
162
168
  self: '/people/1',
163
169
  comments: {
164
170
  self: '/people/1/links/comments',
165
- resource: '/people/1/comments'
171
+ related: '/people/1/comments'
166
172
  },
167
173
  posts: {
168
174
  self: '/people/1/links/posts',
169
- resource: '/people/1/posts'
175
+ related: '/people/1/posts'
176
+ },
177
+ preferences: {
178
+ self: '/people/1/links/preferences',
179
+ related: '/people/1/preferences',
180
+ linkage: {
181
+ type: 'preferences',
182
+ id: '1'
183
+ }
170
184
  }
171
185
  }
172
186
  }
@@ -190,27 +204,29 @@ class SerializerTest < MiniTest::Unit::TestCase
190
204
  self: '/posts/1',
191
205
  section: {
192
206
  self: '/posts/1/links/section',
193
- resource: '/posts/1/section',
194
- type: 'sections',
195
- id: nil
207
+ related: '/posts/1/section',
208
+ linkage: {
209
+ }
196
210
  },
197
211
  author: {
198
212
  self: '/posts/1/links/author',
199
- resource: '/posts/1/author',
200
- type: 'people',
201
- id: '1'
213
+ related: '/posts/1/author',
214
+ linkage: {
215
+ type: 'people',
216
+ id: '1'
217
+ }
202
218
  },
203
219
  tags: {
204
220
  self: '/posts/1/links/tags',
205
- resource: '/posts/1/tags'
221
+ related: '/posts/1/tags'
206
222
  },
207
223
  comments: {
208
224
  self: '/posts/1/links/comments',
209
- resource: '/posts/1/comments'
225
+ related: '/posts/1/comments'
210
226
  }
211
227
  }
212
228
  },
213
- linked: [
229
+ included: [
214
230
  {
215
231
  type: 'people',
216
232
  id: '1',
@@ -221,11 +237,19 @@ class SerializerTest < MiniTest::Unit::TestCase
221
237
  self: '/people/1',
222
238
  comments: {
223
239
  self: '/people/1/links/comments',
224
- resource: '/people/1/comments'
240
+ related: '/people/1/comments'
225
241
  },
226
242
  posts: {
227
243
  self: '/people/1/links/posts',
228
- resource: '/people/1/posts'
244
+ related: '/people/1/posts'
245
+ },
246
+ preferences: {
247
+ self: '/people/1/links/preferences',
248
+ related: '/people/1/preferences',
249
+ linkage: {
250
+ type: 'preferences',
251
+ id: '1'
252
+ }
229
253
  }
230
254
  }
231
255
  }
@@ -251,29 +275,33 @@ class SerializerTest < MiniTest::Unit::TestCase
251
275
  self: '/posts/1',
252
276
  section: {
253
277
  self: '/posts/1/links/section',
254
- resource: '/posts/1/section',
255
- type: 'sections',
256
- id: nil
278
+ related: '/posts/1/section',
279
+ linkage: {
280
+ }
257
281
  },
258
282
  author: {
259
283
  self: '/posts/1/links/author',
260
- resource: '/posts/1/author',
261
- type: 'people',
262
- id: '1'
284
+ related: '/posts/1/author',
285
+ linkage: {
286
+ type: 'people',
287
+ id: '1'
288
+ }
263
289
  },
264
290
  tags: {
265
291
  self: '/posts/1/links/tags',
266
- resource: '/posts/1/tags'
292
+ related: '/posts/1/tags'
267
293
  },
268
294
  comments: {
269
295
  self: '/posts/1/links/comments',
270
- resource: '/posts/1/comments',
271
- type: 'comments',
272
- ids: ['1', '2']
296
+ related: '/posts/1/comments',
297
+ linkage: [
298
+ {type: 'comments', id: '1'},
299
+ {type: 'comments', id: '2'}
300
+ ]
273
301
  }
274
302
  }
275
303
  },
276
- linked: [
304
+ included: [
277
305
  {
278
306
  type: 'tags',
279
307
  id: '1',
@@ -282,7 +310,7 @@ class SerializerTest < MiniTest::Unit::TestCase
282
310
  self: '/tags/1',
283
311
  posts: {
284
312
  self: '/tags/1/links/posts',
285
- resource: '/tags/1/posts'
313
+ related: '/tags/1/posts'
286
314
  }
287
315
  }
288
316
  },
@@ -294,7 +322,7 @@ class SerializerTest < MiniTest::Unit::TestCase
294
322
  self: '/tags/2',
295
323
  posts: {
296
324
  self: '/tags/2/links/posts',
297
- resource: '/tags/2/posts'
325
+ related: '/tags/2/posts'
298
326
  }
299
327
  }
300
328
  },
@@ -306,7 +334,7 @@ class SerializerTest < MiniTest::Unit::TestCase
306
334
  self: '/tags/4',
307
335
  posts: {
308
336
  self: '/tags/4/links/posts',
309
- resource: '/tags/4/posts',
337
+ related: '/tags/4/posts',
310
338
  }
311
339
  }
312
340
  },
@@ -318,21 +346,27 @@ class SerializerTest < MiniTest::Unit::TestCase
318
346
  self: '/comments/1',
319
347
  author: {
320
348
  self: '/comments/1/links/author',
321
- resource: '/comments/1/author',
322
- type: 'people',
323
- id: '1'
349
+ related: '/comments/1/author',
350
+ linkage: {
351
+ type: 'people',
352
+ id: '1'
353
+ }
324
354
  },
325
355
  post: {
326
356
  self: '/comments/1/links/post',
327
- resource: '/comments/1/post',
328
- type: 'posts',
329
- id: '1'
357
+ related: '/comments/1/post',
358
+ linkage: {
359
+ type: 'posts',
360
+ id: '1'
361
+ }
330
362
  },
331
363
  tags: {
332
364
  self: '/comments/1/links/tags',
333
- resource: '/comments/1/tags',
334
- type: 'tags',
335
- ids: ['1', '2']
365
+ related: '/comments/1/tags',
366
+ linkage: [
367
+ {type: 'tags', id: '1'},
368
+ {type: 'tags', id: '2'}
369
+ ]
336
370
  }
337
371
  }
338
372
  },
@@ -344,21 +378,27 @@ class SerializerTest < MiniTest::Unit::TestCase
344
378
  self: '/comments/2',
345
379
  author: {
346
380
  self: '/comments/2/links/author',
347
- resource: '/comments/2/author',
348
- type: 'people',
349
- id: '2'
381
+ related: '/comments/2/author',
382
+ linkage: {
383
+ type: 'people',
384
+ id: '2'
385
+ }
350
386
  },
351
387
  post: {
352
388
  self: '/comments/2/links/post',
353
- resource: '/comments/2/post',
354
- type: 'posts',
355
- id: '1'
389
+ related: '/comments/2/post',
390
+ linkage: {
391
+ type: 'posts',
392
+ id: '1'
393
+ }
356
394
  },
357
395
  tags: {
358
396
  self: '/comments/2/links/tags',
359
- resource: '/comments/2/tags',
360
- type: 'tags',
361
- ids: ['4', '1']
397
+ related: '/comments/2/tags',
398
+ linkage: [
399
+ {type: 'tags', id: '1'},
400
+ {type: 'tags', id: '4'}
401
+ ]
362
402
  }
363
403
  }
364
404
  }
@@ -383,27 +423,29 @@ class SerializerTest < MiniTest::Unit::TestCase
383
423
  self: '/posts/1',
384
424
  section: {
385
425
  self: '/posts/1/links/section',
386
- resource: '/posts/1/section',
387
- type: 'sections',
388
- id: nil
426
+ related: '/posts/1/section',
427
+ linkage: {
428
+ }
389
429
  },
390
430
  author: {
391
431
  self: '/posts/1/links/author',
392
- resource: '/posts/1/author',
393
- type: 'people',
394
- id: '1'
432
+ related: '/posts/1/author',
433
+ linkage: {
434
+ type: 'people',
435
+ id: '1'
436
+ }
395
437
  },
396
438
  tags: {
397
439
  self: '/posts/1/links/tags',
398
- resource: '/posts/1/tags'
440
+ related: '/posts/1/tags'
399
441
  },
400
442
  comments: {
401
443
  self: '/posts/1/links/comments',
402
- resource: '/posts/1/comments'
444
+ related: '/posts/1/comments'
403
445
  }
404
446
  }
405
447
  },
406
- linked: [
448
+ included: [
407
449
  {
408
450
  type: 'tags',
409
451
  id: '1',
@@ -412,7 +454,7 @@ class SerializerTest < MiniTest::Unit::TestCase
412
454
  self: '/tags/1',
413
455
  posts: {
414
456
  self: '/tags/1/links/posts',
415
- resource: '/tags/1/posts'
457
+ related: '/tags/1/posts'
416
458
  }
417
459
  }
418
460
  },
@@ -424,7 +466,7 @@ class SerializerTest < MiniTest::Unit::TestCase
424
466
  self: '/tags/2',
425
467
  posts: {
426
468
  self: '/tags/2/links/posts',
427
- resource: '/tags/2/posts'
469
+ related: '/tags/2/posts'
428
470
  }
429
471
  }
430
472
  },
@@ -436,7 +478,7 @@ class SerializerTest < MiniTest::Unit::TestCase
436
478
  self: '/tags/4',
437
479
  posts: {
438
480
  self: '/tags/4/links/posts',
439
- resource: '/tags/4/posts',
481
+ related: '/tags/4/posts',
440
482
  }
441
483
  }
442
484
  }
@@ -460,27 +502,29 @@ class SerializerTest < MiniTest::Unit::TestCase
460
502
  self: '/posts/1',
461
503
  section: {
462
504
  self: '/posts/1/links/section',
463
- resource: '/posts/1/section',
464
- type: 'sections',
465
- id: nil
505
+ related: '/posts/1/section',
506
+ linkage: {
507
+ }
466
508
  },
467
509
  author: {
468
510
  self: '/posts/1/links/author',
469
- resource: '/posts/1/author',
470
- type: 'people',
471
- id: '1'
511
+ related: '/posts/1/author',
512
+ linkage: {
513
+ type: 'people',
514
+ id: '1'
515
+ }
472
516
  },
473
517
  tags: {
474
518
  self: '/posts/1/links/tags',
475
- resource: '/posts/1/tags'
519
+ related: '/posts/1/tags'
476
520
  },
477
521
  comments: {
478
522
  self: '/posts/1/links/comments',
479
- resource: '/posts/1/comments'
523
+ related: '/posts/1/comments'
480
524
  }
481
525
  }
482
526
  },
483
- linked: [
527
+ included: [
484
528
  {
485
529
  type: 'comments',
486
530
  id: '1',
@@ -489,19 +533,23 @@ class SerializerTest < MiniTest::Unit::TestCase
489
533
  self: '/comments/1',
490
534
  author: {
491
535
  self: '/comments/1/links/author',
492
- resource: '/comments/1/author',
493
- type: 'people',
494
- id: '1'
536
+ related: '/comments/1/author',
537
+ linkage: {
538
+ type: 'people',
539
+ id: '1'
540
+ }
495
541
  },
496
542
  post: {
497
543
  self: '/comments/1/links/post',
498
- resource: '/comments/1/post',
499
- type: 'posts',
500
- id: '1'
544
+ related: '/comments/1/post',
545
+ linkage: {
546
+ type: 'posts',
547
+ id: '1'
548
+ }
501
549
  },
502
550
  tags: {
503
551
  self: '/comments/1/links/tags',
504
- resource: '/comments/1/tags'
552
+ related: '/comments/1/tags'
505
553
  }
506
554
  }
507
555
  }
@@ -526,17 +574,25 @@ class SerializerTest < MiniTest::Unit::TestCase
526
574
  self: '/people/2',
527
575
  posts: {
528
576
  self: '/people/2/links/posts',
529
- resource: '/people/2/posts'
577
+ related: '/people/2/posts'
530
578
  },
531
579
  comments: {
532
580
  self: '/people/2/links/comments',
533
- resource: '/people/2/comments',
534
- type: 'comments',
535
- ids: ['2', '3']
581
+ related: '/people/2/comments',
582
+ linkage: [
583
+ {type: 'comments', id: '2'},
584
+ {type: 'comments', id: '3'}
585
+ ]
586
+ },
587
+ preferences: {
588
+ self: "/people/2/links/preferences",
589
+ related: "/people/2/preferences",
590
+ linkage: {
591
+ }
536
592
  }
537
593
  }
538
594
  },
539
- linked: [
595
+ included: [
540
596
  {
541
597
  type: 'comments',
542
598
  id: '2',
@@ -545,19 +601,23 @@ class SerializerTest < MiniTest::Unit::TestCase
545
601
  self: '/comments/2',
546
602
  author: {
547
603
  self: '/comments/2/links/author',
548
- resource: '/comments/2/author',
549
- type: 'people',
550
- id: '2'
604
+ related: '/comments/2/author',
605
+ linkage: {
606
+ type: 'people',
607
+ id: '2'
608
+ }
551
609
  },
552
610
  post: {
553
611
  self: '/comments/2/links/post',
554
- resource: '/comments/2/post',
555
- type: 'posts',
556
- id: '1'
612
+ related: '/comments/2/post',
613
+ linkage: {
614
+ type: 'posts',
615
+ id: '1'
616
+ }
557
617
  },
558
618
  tags: {
559
619
  self: '/comments/2/links/tags',
560
- resource: '/comments/2/tags'
620
+ related: '/comments/2/tags'
561
621
  }
562
622
  }
563
623
  },
@@ -569,19 +629,23 @@ class SerializerTest < MiniTest::Unit::TestCase
569
629
  self: '/comments/3',
570
630
  author: {
571
631
  self: '/comments/3/links/author',
572
- resource: '/comments/3/author',
573
- type: 'people',
574
- id: '2'
632
+ related: '/comments/3/author',
633
+ linkage: {
634
+ type: 'people',
635
+ id: '2'
636
+ }
575
637
  },
576
638
  post: {
577
639
  self: '/comments/3/links/post',
578
- resource: '/comments/3/post',
579
- type: 'posts',
580
- id: '2'
640
+ related: '/comments/3/post',
641
+ linkage: {
642
+ type: 'posts',
643
+ id: '2'
644
+ }
581
645
  },
582
646
  tags: {
583
647
  self: '/comments/3/links/tags',
584
- resource: '/comments/3/tags'
648
+ related: '/comments/3/tags'
585
649
  }
586
650
  }
587
651
  }
@@ -611,25 +675,29 @@ class SerializerTest < MiniTest::Unit::TestCase
611
675
  self: '/posts/1',
612
676
  section: {
613
677
  self: '/posts/1/links/section',
614
- resource: '/posts/1/section',
615
- type: 'sections',
616
- id: nil
678
+ related: '/posts/1/section',
679
+ linkage: {
680
+ }
617
681
  },
618
682
  author: {
619
683
  self: '/posts/1/links/author',
620
- resource: '/posts/1/author',
621
- type: 'people',
622
- id: '1'
684
+ related: '/posts/1/author',
685
+ linkage: {
686
+ type: 'people',
687
+ id: '1'
688
+ }
623
689
  },
624
690
  tags: {
625
691
  self: '/posts/1/links/tags',
626
- resource: '/posts/1/tags'
692
+ related: '/posts/1/tags'
627
693
  },
628
694
  comments: {
629
695
  self: '/posts/1/links/comments',
630
- resource: '/posts/1/comments',
631
- type: 'comments',
632
- ids: ['1', '2']
696
+ related: '/posts/1/comments',
697
+ linkage: [
698
+ {type: 'comments', id: '1'},
699
+ {type: 'comments', id: '2'}
700
+ ]
633
701
  }
634
702
  }
635
703
  },
@@ -643,30 +711,35 @@ class SerializerTest < MiniTest::Unit::TestCase
643
711
  self: '/posts/2',
644
712
  section: {
645
713
  self: '/posts/2/links/section',
646
- resource: '/posts/2/section',
647
- type: 'sections',
648
- id: '3'
714
+ related: '/posts/2/section',
715
+ linkage: {
716
+ type: 'sections',
717
+ id: '2'
718
+ }
649
719
  },
650
720
  author: {
651
721
  self: '/posts/2/links/author',
652
- resource: '/posts/2/author',
653
- type: 'people',
654
- id: '1'
722
+ related: '/posts/2/author',
723
+ linkage: {
724
+ type: 'people',
725
+ id: '1'
726
+ }
655
727
  },
656
728
  tags: {
657
729
  self: '/posts/2/links/tags',
658
- resource: '/posts/2/tags'
730
+ related: '/posts/2/tags'
659
731
  },
660
732
  comments: {
661
733
  self: '/posts/2/links/comments',
662
- resource: '/posts/2/comments',
663
- type: 'comments',
664
- ids: ['3']
734
+ related: '/posts/2/comments',
735
+ linkage: [
736
+ {type: 'comments', id: '3'}
737
+ ]
665
738
  }
666
739
  }
667
740
  }
668
741
  ],
669
- linked: [
742
+ included: [
670
743
  {
671
744
  type: 'tags',
672
745
  id: '1',
@@ -675,7 +748,7 @@ class SerializerTest < MiniTest::Unit::TestCase
675
748
  self: '/tags/1',
676
749
  posts: {
677
750
  self: '/tags/1/links/posts',
678
- resource: '/tags/1/posts'
751
+ related: '/tags/1/posts'
679
752
  }
680
753
  }
681
754
  },
@@ -687,7 +760,7 @@ class SerializerTest < MiniTest::Unit::TestCase
687
760
  self: '/tags/2',
688
761
  posts: {
689
762
  self: '/tags/2/links/posts',
690
- resource: '/tags/2/posts'
763
+ related: '/tags/2/posts'
691
764
  }
692
765
  }
693
766
  },
@@ -699,7 +772,7 @@ class SerializerTest < MiniTest::Unit::TestCase
699
772
  self: '/tags/4',
700
773
  posts: {
701
774
  self: '/tags/4/links/posts',
702
- resource: '/tags/4/posts',
775
+ related: '/tags/4/posts',
703
776
  }
704
777
  }
705
778
  },
@@ -711,7 +784,7 @@ class SerializerTest < MiniTest::Unit::TestCase
711
784
  self: '/tags/5',
712
785
  posts: {
713
786
  self: '/tags/5/links/posts',
714
- resource: '/tags/5/posts',
787
+ related: '/tags/5/posts',
715
788
  }
716
789
  }
717
790
  },
@@ -723,21 +796,27 @@ class SerializerTest < MiniTest::Unit::TestCase
723
796
  self: '/comments/1',
724
797
  author: {
725
798
  self: '/comments/1/links/author',
726
- resource: '/comments/1/author',
727
- type: 'people',
728
- id: '1'
799
+ related: '/comments/1/author',
800
+ linkage: {
801
+ type: 'people',
802
+ id: '1'
803
+ }
729
804
  },
730
805
  post: {
731
806
  self: '/comments/1/links/post',
732
- resource: '/comments/1/post',
733
- type: 'posts',
734
- id: '1'
807
+ related: '/comments/1/post',
808
+ linkage: {
809
+ type: 'posts',
810
+ id: '1'
811
+ }
735
812
  },
736
813
  tags: {
737
814
  self: '/comments/1/links/tags',
738
- resource: '/comments/1/tags',
739
- type: 'tags',
740
- ids: ['1', '2']
815
+ related: '/comments/1/tags',
816
+ linkage: [
817
+ {type: 'tags', id: '1'},
818
+ {type: 'tags', id: '2'}
819
+ ]
741
820
  }
742
821
  }
743
822
  },
@@ -749,21 +828,27 @@ class SerializerTest < MiniTest::Unit::TestCase
749
828
  self: '/comments/2',
750
829
  author: {
751
830
  self: '/comments/2/links/author',
752
- resource: '/comments/2/author',
753
- type: 'people',
754
- id: '2'
831
+ related: '/comments/2/author',
832
+ linkage: {
833
+ type: 'people',
834
+ id: '2'
835
+ }
755
836
  },
756
837
  post: {
757
838
  self: '/comments/2/links/post',
758
- resource: '/comments/2/post',
759
- type: 'posts',
760
- id: '1'
839
+ related: '/comments/2/post',
840
+ linkage: {
841
+ type: 'posts',
842
+ id: '1'
843
+ }
761
844
  },
762
845
  tags: {
763
846
  self: '/comments/2/links/tags',
764
- resource: '/comments/2/tags',
765
- type: 'tags',
766
- ids: ['4', '1']
847
+ related: '/comments/2/tags',
848
+ linkage: [
849
+ {type: 'tags', id: '4'},
850
+ {type: 'tags', id: '1'}
851
+ ]
767
852
  }
768
853
  }
769
854
  },
@@ -775,21 +860,26 @@ class SerializerTest < MiniTest::Unit::TestCase
775
860
  self: '/comments/3',
776
861
  author: {
777
862
  self: '/comments/3/links/author',
778
- resource: '/comments/3/author',
779
- type: 'people',
780
- id: '2'
863
+ related: '/comments/3/author',
864
+ linkage: {
865
+ type: 'people',
866
+ id: '2'
867
+ }
781
868
  },
782
869
  post: {
783
870
  self: '/comments/3/links/post',
784
- resource: '/comments/3/post',
785
- type: 'posts',
786
- id: '2'
871
+ related: '/comments/3/post',
872
+ linkage: {
873
+ type: 'posts',
874
+ id: '2'
875
+ }
787
876
  },
788
877
  tags: {
789
878
  self: '/comments/3/links/tags',
790
- resource: '/comments/3/tags',
791
- type: 'tags',
792
- ids: ['5']
879
+ related: '/comments/3/tags',
880
+ linkage: [
881
+ {type: 'tags', id: '5'}
882
+ ]
793
883
  }
794
884
  }
795
885
  }
@@ -818,9 +908,11 @@ class SerializerTest < MiniTest::Unit::TestCase
818
908
  self: '/posts/1',
819
909
  author: {
820
910
  self: '/posts/1/links/author',
821
- resource: '/posts/1/author',
822
- type: 'people',
823
- id: '1'
911
+ related: '/posts/1/author',
912
+ linkage: {
913
+ type: 'people',
914
+ id: '1'
915
+ }
824
916
  }
825
917
  }
826
918
  },
@@ -832,14 +924,16 @@ class SerializerTest < MiniTest::Unit::TestCase
832
924
  self: '/posts/2',
833
925
  author: {
834
926
  self: '/posts/2/links/author',
835
- resource: '/posts/2/author',
836
- type: 'people',
837
- id: '1'
927
+ related: '/posts/2/author',
928
+ linkage: {
929
+ type: 'people',
930
+ id: '1'
931
+ }
838
932
  }
839
933
  }
840
934
  }
841
935
  ],
842
- linked: [
936
+ included: [
843
937
  {
844
938
  type: 'posts',
845
939
  id: '11',
@@ -848,9 +942,11 @@ class SerializerTest < MiniTest::Unit::TestCase
848
942
  self: '/posts/11',
849
943
  author: {
850
944
  self: '/posts/11/links/author',
851
- resource: '/posts/11/author',
852
- type: 'people',
853
- id: '1'
945
+ related: '/posts/11/author',
946
+ linkage: {
947
+ type: 'people',
948
+ id: '1'
949
+ }
854
950
  }
855
951
  }
856
952
  },
@@ -862,7 +958,7 @@ class SerializerTest < MiniTest::Unit::TestCase
862
958
  self: '/people/1',
863
959
  comments: {
864
960
  self: '/people/1/links/comments',
865
- resource: '/people/1/comments'
961
+ related: '/people/1/comments'
866
962
  }
867
963
  }
868
964
  },
@@ -906,9 +1002,11 @@ class SerializerTest < MiniTest::Unit::TestCase
906
1002
  self: '/comments/1',
907
1003
  post: {
908
1004
  self: '/comments/1/links/post',
909
- resource: '/comments/1/post',
910
- type: 'posts',
911
- id: '1'
1005
+ related: '/comments/1/post',
1006
+ linkage: {
1007
+ type: 'posts',
1008
+ id: '1'
1009
+ }
912
1010
  }
913
1011
  }
914
1012
  },
@@ -920,9 +1018,11 @@ class SerializerTest < MiniTest::Unit::TestCase
920
1018
  self: '/comments/2',
921
1019
  post: {
922
1020
  self: '/comments/2/links/post',
923
- resource: '/comments/2/post',
924
- type: 'posts',
925
- id: '1'
1021
+ related: '/comments/2/post',
1022
+ linkage: {
1023
+ type: 'posts',
1024
+ id: '1'
1025
+ }
926
1026
  }
927
1027
  }
928
1028
  },
@@ -934,9 +1034,11 @@ class SerializerTest < MiniTest::Unit::TestCase
934
1034
  self: '/comments/3',
935
1035
  post: {
936
1036
  self: '/comments/3/links/post',
937
- resource: '/comments/3/post',
938
- type: 'posts',
939
- id: '2'
1037
+ related: '/comments/3/post',
1038
+ linkage: {
1039
+ type: 'posts',
1040
+ id: '2'
1041
+ }
940
1042
  }
941
1043
  }
942
1044
  }
@@ -965,19 +1067,23 @@ class SerializerTest < MiniTest::Unit::TestCase
965
1067
  self: '/expense_entries/1',
966
1068
  isoCurrency: {
967
1069
  self: '/expense_entries/1/links/iso_currency',
968
- resource: '/expense_entries/1/iso_currency',
969
- type: 'iso_currencies',
970
- id: 'USD'
1070
+ related: '/expense_entries/1/iso_currency',
1071
+ linkage: {
1072
+ type: 'iso_currencies',
1073
+ id: 'USD'
1074
+ }
971
1075
  },
972
1076
  employee: {
973
1077
  self: '/expense_entries/1/links/employee',
974
- resource: '/expense_entries/1/employee',
975
- type: 'people',
976
- id: '3'
1078
+ related: '/expense_entries/1/employee',
1079
+ linkage: {
1080
+ type: 'people',
1081
+ id: '3'
1082
+ }
977
1083
  }
978
1084
  }
979
1085
  },
980
- linked: [
1086
+ included: [
981
1087
  {
982
1088
  type: 'iso_currencies',
983
1089
  id: 'USD',
@@ -1022,17 +1128,17 @@ class SerializerTest < MiniTest::Unit::TestCase
1022
1128
  self: '/planets/8',
1023
1129
  planetType: {
1024
1130
  self: '/planets/8/links/planet_type',
1025
- resource: '/planets/8/planet_type',
1026
- type: 'planet_types',
1027
- id: nil
1131
+ related: '/planets/8/planet_type',
1132
+ linkage: {
1133
+ }
1028
1134
  },
1029
1135
  tags: {
1030
1136
  self: '/planets/8/links/tags',
1031
- resource: '/planets/8/tags'
1137
+ related: '/planets/8/tags'
1032
1138
  },
1033
1139
  moons: {
1034
1140
  self: '/planets/8/links/moons',
1035
- resource: '/planets/8/moons'
1141
+ related: '/planets/8/moons'
1036
1142
  }
1037
1143
  }
1038
1144
  }
@@ -1060,17 +1166,19 @@ class SerializerTest < MiniTest::Unit::TestCase
1060
1166
  self: '/planets/7',
1061
1167
  planetType: {
1062
1168
  self: '/planets/7/links/planet_type',
1063
- resource: '/planets/7/planet_type',
1064
- type: 'planet_types',
1065
- id: '5'
1169
+ related: '/planets/7/planet_type',
1170
+ linkage: {
1171
+ type: 'planet_types',
1172
+ id: '5'
1173
+ }
1066
1174
  },
1067
1175
  tags: {
1068
1176
  self: '/planets/7/links/tags',
1069
- resource: '/planets/7/tags'
1177
+ related: '/planets/7/tags'
1070
1178
  },
1071
1179
  moons: {
1072
1180
  self: '/planets/7/links/moons',
1073
- resource: '/planets/7/moons'
1181
+ related: '/planets/7/moons'
1074
1182
  }
1075
1183
  }
1076
1184
  },
@@ -1083,22 +1191,22 @@ class SerializerTest < MiniTest::Unit::TestCase
1083
1191
  self: '/planets/8',
1084
1192
  planetType: {
1085
1193
  self: '/planets/8/links/planet_type',
1086
- resource: '/planets/8/planet_type',
1087
- type: 'planet_types',
1088
- id: nil
1194
+ related: '/planets/8/planet_type',
1195
+ linkage: {
1196
+ }
1089
1197
  },
1090
1198
  tags: {
1091
1199
  self: '/planets/8/links/tags',
1092
- resource: '/planets/8/tags'
1200
+ related: '/planets/8/tags'
1093
1201
  },
1094
1202
  moons: {
1095
1203
  self: '/planets/8/links/moons',
1096
- resource: '/planets/8/moons'
1204
+ related: '/planets/8/moons'
1097
1205
  }
1098
1206
  }
1099
1207
  }
1100
1208
  ],
1101
- linked: [
1209
+ included: [
1102
1210
  {
1103
1211
  type: 'planet_types',
1104
1212
  id: '5',
@@ -1126,13 +1234,13 @@ class SerializerTest < MiniTest::Unit::TestCase
1126
1234
  self: '/preferences/1',
1127
1235
  author: {
1128
1236
  self: '/preferences/1/links/author',
1129
- resource: '/preferences/1/author',
1130
- type: 'authors',
1131
- id: nil
1237
+ related: '/preferences/1/author',
1238
+ linkage: {
1239
+ }
1132
1240
  },
1133
1241
  friends: {
1134
1242
  self: '/preferences/1/links/friends',
1135
- resource: '/preferences/1/friends'
1243
+ related: '/preferences/1/friends'
1136
1244
  }
1137
1245
  }
1138
1246
  }