jsonapi-resources 0.2.0 → 0.3.0.pre1
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.
- checksums.yaml +4 -4
- data/.gitignore +3 -1
- data/.travis.yml +5 -2
- data/Gemfile +3 -1
- data/README.md +52 -13
- data/jsonapi-resources.gemspec +1 -1
- data/lib/jsonapi-resources.rb +1 -0
- data/lib/jsonapi/association.rb +1 -9
- data/lib/jsonapi/error_codes.rb +1 -0
- data/lib/jsonapi/exceptions.rb +9 -5
- data/lib/jsonapi/formatter.rb +9 -18
- data/lib/jsonapi/paginator.rb +4 -15
- data/lib/jsonapi/request.rb +26 -42
- data/lib/jsonapi/resource.rb +35 -45
- data/lib/jsonapi/resource_controller.rb +6 -32
- data/lib/jsonapi/resource_serializer.rb +62 -33
- data/lib/jsonapi/resources/version.rb +1 -1
- data/lib/jsonapi/routing_ext.rb +4 -4
- data/test/config/database.yml +2 -1
- data/test/controllers/controller_test.rb +200 -160
- data/test/fixtures/active_record.rb +44 -201
- data/test/fixtures/book_comments.yml +11 -0
- data/test/fixtures/books.yml +6 -0
- data/test/fixtures/comments.yml +17 -0
- data/test/fixtures/comments_tags.yml +20 -0
- data/test/fixtures/expense_entries.yml +13 -0
- data/test/fixtures/facts.yml +11 -0
- data/test/fixtures/iso_currencies.yml +17 -0
- data/test/fixtures/people.yml +24 -0
- data/test/fixtures/posts.yml +96 -0
- data/test/fixtures/posts_tags.yml +59 -0
- data/test/fixtures/preferences.yml +18 -0
- data/test/fixtures/sections.yml +8 -0
- data/test/fixtures/tags.yml +39 -0
- data/test/helpers/hash_helpers.rb +0 -7
- data/test/integration/requests/request_test.rb +86 -28
- data/test/integration/routes/routes_test.rb +14 -25
- data/test/test_helper.rb +41 -17
- data/test/unit/jsonapi_request/jsonapi_request_test.rb +152 -0
- data/test/unit/operation/operations_processor_test.rb +13 -2
- data/test/unit/resource/resource_test.rb +68 -13
- data/test/unit/serializer/serializer_test.rb +328 -220
- metadata +33 -6
- 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 <
|
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
|
-
|
35
|
-
|
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
|
-
|
41
|
-
|
42
|
-
|
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
|
-
|
46
|
+
related: 'http://example.com/posts/1/tags'
|
47
47
|
},
|
48
48
|
comments: {
|
49
49
|
self: 'http://example.com/posts/1/links/comments',
|
50
|
-
|
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
|
-
|
74
|
-
|
75
|
-
|
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
|
-
|
80
|
-
|
81
|
-
|
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
|
-
|
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
|
-
|
109
|
-
|
110
|
-
|
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
|
-
|
135
|
-
|
136
|
-
|
138
|
+
related: '/posts/1/section',
|
139
|
+
linkage: {
|
140
|
+
}
|
137
141
|
},
|
138
142
|
author: {
|
139
143
|
self: '/posts/1/links/author',
|
140
|
-
|
141
|
-
|
142
|
-
|
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
|
-
|
152
|
+
related: '/posts/1/tags'
|
147
153
|
},
|
148
154
|
comments: {
|
149
155
|
self: '/posts/1/links/comments',
|
150
|
-
|
156
|
+
related: '/posts/1/comments'
|
151
157
|
}
|
152
158
|
}
|
153
159
|
},
|
154
|
-
|
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
|
-
|
171
|
+
related: '/people/1/comments'
|
166
172
|
},
|
167
173
|
posts: {
|
168
174
|
self: '/people/1/links/posts',
|
169
|
-
|
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
|
-
|
194
|
-
|
195
|
-
|
207
|
+
related: '/posts/1/section',
|
208
|
+
linkage: {
|
209
|
+
}
|
196
210
|
},
|
197
211
|
author: {
|
198
212
|
self: '/posts/1/links/author',
|
199
|
-
|
200
|
-
|
201
|
-
|
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
|
-
|
221
|
+
related: '/posts/1/tags'
|
206
222
|
},
|
207
223
|
comments: {
|
208
224
|
self: '/posts/1/links/comments',
|
209
|
-
|
225
|
+
related: '/posts/1/comments'
|
210
226
|
}
|
211
227
|
}
|
212
228
|
},
|
213
|
-
|
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
|
-
|
240
|
+
related: '/people/1/comments'
|
225
241
|
},
|
226
242
|
posts: {
|
227
243
|
self: '/people/1/links/posts',
|
228
|
-
|
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
|
-
|
255
|
-
|
256
|
-
|
278
|
+
related: '/posts/1/section',
|
279
|
+
linkage: {
|
280
|
+
}
|
257
281
|
},
|
258
282
|
author: {
|
259
283
|
self: '/posts/1/links/author',
|
260
|
-
|
261
|
-
|
262
|
-
|
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
|
-
|
292
|
+
related: '/posts/1/tags'
|
267
293
|
},
|
268
294
|
comments: {
|
269
295
|
self: '/posts/1/links/comments',
|
270
|
-
|
271
|
-
|
272
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
322
|
-
|
323
|
-
|
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
|
-
|
328
|
-
|
329
|
-
|
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
|
-
|
334
|
-
|
335
|
-
|
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
|
-
|
348
|
-
|
349
|
-
|
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
|
-
|
354
|
-
|
355
|
-
|
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
|
-
|
360
|
-
|
361
|
-
|
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
|
-
|
387
|
-
|
388
|
-
|
426
|
+
related: '/posts/1/section',
|
427
|
+
linkage: {
|
428
|
+
}
|
389
429
|
},
|
390
430
|
author: {
|
391
431
|
self: '/posts/1/links/author',
|
392
|
-
|
393
|
-
|
394
|
-
|
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
|
-
|
440
|
+
related: '/posts/1/tags'
|
399
441
|
},
|
400
442
|
comments: {
|
401
443
|
self: '/posts/1/links/comments',
|
402
|
-
|
444
|
+
related: '/posts/1/comments'
|
403
445
|
}
|
404
446
|
}
|
405
447
|
},
|
406
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
464
|
-
|
465
|
-
|
505
|
+
related: '/posts/1/section',
|
506
|
+
linkage: {
|
507
|
+
}
|
466
508
|
},
|
467
509
|
author: {
|
468
510
|
self: '/posts/1/links/author',
|
469
|
-
|
470
|
-
|
471
|
-
|
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
|
-
|
519
|
+
related: '/posts/1/tags'
|
476
520
|
},
|
477
521
|
comments: {
|
478
522
|
self: '/posts/1/links/comments',
|
479
|
-
|
523
|
+
related: '/posts/1/comments'
|
480
524
|
}
|
481
525
|
}
|
482
526
|
},
|
483
|
-
|
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
|
-
|
493
|
-
|
494
|
-
|
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
|
-
|
499
|
-
|
500
|
-
|
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
|
-
|
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
|
-
|
577
|
+
related: '/people/2/posts'
|
530
578
|
},
|
531
579
|
comments: {
|
532
580
|
self: '/people/2/links/comments',
|
533
|
-
|
534
|
-
|
535
|
-
|
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
|
-
|
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
|
-
|
549
|
-
|
550
|
-
|
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
|
-
|
555
|
-
|
556
|
-
|
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
|
-
|
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
|
-
|
573
|
-
|
574
|
-
|
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
|
-
|
579
|
-
|
580
|
-
|
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
|
-
|
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
|
-
|
615
|
-
|
616
|
-
|
678
|
+
related: '/posts/1/section',
|
679
|
+
linkage: {
|
680
|
+
}
|
617
681
|
},
|
618
682
|
author: {
|
619
683
|
self: '/posts/1/links/author',
|
620
|
-
|
621
|
-
|
622
|
-
|
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
|
-
|
692
|
+
related: '/posts/1/tags'
|
627
693
|
},
|
628
694
|
comments: {
|
629
695
|
self: '/posts/1/links/comments',
|
630
|
-
|
631
|
-
|
632
|
-
|
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
|
-
|
647
|
-
|
648
|
-
|
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
|
-
|
653
|
-
|
654
|
-
|
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
|
-
|
730
|
+
related: '/posts/2/tags'
|
659
731
|
},
|
660
732
|
comments: {
|
661
733
|
self: '/posts/2/links/comments',
|
662
|
-
|
663
|
-
|
664
|
-
|
734
|
+
related: '/posts/2/comments',
|
735
|
+
linkage: [
|
736
|
+
{type: 'comments', id: '3'}
|
737
|
+
]
|
665
738
|
}
|
666
739
|
}
|
667
740
|
}
|
668
741
|
],
|
669
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
727
|
-
|
728
|
-
|
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
|
-
|
733
|
-
|
734
|
-
|
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
|
-
|
739
|
-
|
740
|
-
|
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
|
-
|
753
|
-
|
754
|
-
|
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
|
-
|
759
|
-
|
760
|
-
|
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
|
-
|
765
|
-
|
766
|
-
|
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
|
-
|
779
|
-
|
780
|
-
|
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
|
-
|
785
|
-
|
786
|
-
|
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
|
-
|
791
|
-
|
792
|
-
|
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
|
-
|
822
|
-
|
823
|
-
|
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
|
-
|
836
|
-
|
837
|
-
|
927
|
+
related: '/posts/2/author',
|
928
|
+
linkage: {
|
929
|
+
type: 'people',
|
930
|
+
id: '1'
|
931
|
+
}
|
838
932
|
}
|
839
933
|
}
|
840
934
|
}
|
841
935
|
],
|
842
|
-
|
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
|
-
|
852
|
-
|
853
|
-
|
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
|
-
|
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
|
-
|
910
|
-
|
911
|
-
|
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
|
-
|
924
|
-
|
925
|
-
|
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
|
-
|
938
|
-
|
939
|
-
|
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
|
-
|
969
|
-
|
970
|
-
|
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
|
-
|
975
|
-
|
976
|
-
|
1078
|
+
related: '/expense_entries/1/employee',
|
1079
|
+
linkage: {
|
1080
|
+
type: 'people',
|
1081
|
+
id: '3'
|
1082
|
+
}
|
977
1083
|
}
|
978
1084
|
}
|
979
1085
|
},
|
980
|
-
|
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
|
-
|
1026
|
-
|
1027
|
-
|
1131
|
+
related: '/planets/8/planet_type',
|
1132
|
+
linkage: {
|
1133
|
+
}
|
1028
1134
|
},
|
1029
1135
|
tags: {
|
1030
1136
|
self: '/planets/8/links/tags',
|
1031
|
-
|
1137
|
+
related: '/planets/8/tags'
|
1032
1138
|
},
|
1033
1139
|
moons: {
|
1034
1140
|
self: '/planets/8/links/moons',
|
1035
|
-
|
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
|
-
|
1064
|
-
|
1065
|
-
|
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
|
-
|
1177
|
+
related: '/planets/7/tags'
|
1070
1178
|
},
|
1071
1179
|
moons: {
|
1072
1180
|
self: '/planets/7/links/moons',
|
1073
|
-
|
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
|
-
|
1087
|
-
|
1088
|
-
|
1194
|
+
related: '/planets/8/planet_type',
|
1195
|
+
linkage: {
|
1196
|
+
}
|
1089
1197
|
},
|
1090
1198
|
tags: {
|
1091
1199
|
self: '/planets/8/links/tags',
|
1092
|
-
|
1200
|
+
related: '/planets/8/tags'
|
1093
1201
|
},
|
1094
1202
|
moons: {
|
1095
1203
|
self: '/planets/8/links/moons',
|
1096
|
-
|
1204
|
+
related: '/planets/8/moons'
|
1097
1205
|
}
|
1098
1206
|
}
|
1099
1207
|
}
|
1100
1208
|
],
|
1101
|
-
|
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
|
-
|
1130
|
-
|
1131
|
-
|
1237
|
+
related: '/preferences/1/author',
|
1238
|
+
linkage: {
|
1239
|
+
}
|
1132
1240
|
},
|
1133
1241
|
friends: {
|
1134
1242
|
self: '/preferences/1/links/friends',
|
1135
|
-
|
1243
|
+
related: '/preferences/1/friends'
|
1136
1244
|
}
|
1137
1245
|
}
|
1138
1246
|
}
|