@@ -296,15 +296,37 @@ def test_index_filter_not_allowed
296
296
end
297
297
298
298
def test_index_include_one_level_query_count
299
- assert_query_count ( through_primary? ? 4 : 2 ) do
299
+ expected_count = case
300
+ when testing_v09?
301
+ 2
302
+ when testing_v10?
303
+ 4
304
+ when through_primary?
305
+ 3
306
+ else
307
+ 2
308
+ end
309
+
310
+ assert_query_count ( expected_count ) do
300
311
assert_cacheable_get :index , params : { include : 'author' }
301
312
end
302
313
303
314
assert_response :success
304
315
end
305
316
306
317
def test_index_include_two_levels_query_count
307
- assert_query_count ( through_primary? ? 6 : 3 ) do
318
+ expected_count = case
319
+ when testing_v09?
320
+ 3
321
+ when testing_v10?
322
+ 6
323
+ when through_primary?
324
+ 5
325
+ else
326
+ 3
327
+ end
328
+
329
+ assert_query_count ( expected_count ) do
308
330
assert_cacheable_get :index , params : { include : 'author,author.comments' }
309
331
end
310
332
assert_response :success
@@ -355,7 +377,7 @@ def test_index_filter_by_ids_and_fields_2
355
377
end
356
378
357
379
def test_filter_relationship_single
358
- assert_query_count ( through_primary ? ? 2 : 1 ) do
380
+ assert_query_count ( testing_v10 ? ? 2 : 1 ) do
359
381
assert_cacheable_get :index , params : { filter : { tags : '505,501' } }
360
382
end
361
383
assert_response :success
@@ -366,7 +388,7 @@ def test_filter_relationship_single
366
388
end
367
389
368
390
def test_filter_relationships_multiple
369
- assert_query_count ( through_primary ? ? 2 : 1 ) do
391
+ assert_query_count ( testing_v10 ? ? 2 : 1 ) do
370
392
assert_cacheable_get :index , params : { filter : { tags : '505,501' , comments : '3' } }
371
393
end
372
394
assert_response :success
@@ -3303,7 +3325,18 @@ def test_books_offset_pagination_no_params_includes_query_count_one_level
3303
3325
3304
3326
with_jsonapi_config_changes do
3305
3327
JSONAPI . configuration . json_key_format = :dasherized_key
3306
- assert_query_count ( through_primary? ? 5 : 3 ) do
3328
+ expected_count = case
3329
+ when testing_v09?
3330
+ 3
3331
+ when testing_v10?
3332
+ 5
3333
+ when through_primary?
3334
+ 4
3335
+ else
3336
+ 3
3337
+ end
3338
+
3339
+ assert_query_count ( expected_count ) do
3307
3340
assert_cacheable_get :index , params : { include : 'book-comments' }
3308
3341
end
3309
3342
assert_response :success
@@ -3317,7 +3350,18 @@ def test_books_offset_pagination_no_params_includes_query_count_two_levels
3317
3350
with_jsonapi_config_changes do
3318
3351
JSONAPI . configuration . json_key_format = :dasherized_key
3319
3352
3320
- assert_query_count ( through_primary? ? 7 : 4 ) do
3353
+ expected_count = case
3354
+ when testing_v09?
3355
+ 4
3356
+ when testing_v10?
3357
+ 7
3358
+ when through_primary?
3359
+ 6
3360
+ else
3361
+ 4
3362
+ end
3363
+
3364
+ assert_query_count ( expected_count ) do
3321
3365
assert_cacheable_get :index , params : { include : 'book-comments,book-comments.author' }
3322
3366
end
3323
3367
assert_response :success
@@ -3451,7 +3495,18 @@ def test_books_included_paged
3451
3495
3452
3496
with_jsonapi_config_changes do
3453
3497
JSONAPI . configuration . json_key_format = :dasherized_key
3454
- assert_query_count ( through_primary? ? 5 : 3 ) do
3498
+ expected_count = case
3499
+ when testing_v09?
3500
+ 3
3501
+ when testing_v10?
3502
+ 5
3503
+ when through_primary?
3504
+ 4
3505
+ else
3506
+ 3
3507
+ end
3508
+
3509
+ assert_query_count ( expected_count ) do
3455
3510
assert_cacheable_get :index , params : { filter : { id : '0' } , include : 'book-comments' }
3456
3511
assert_response :success
3457
3512
assert_equal 1 , json_response [ 'data' ] . size
@@ -3468,7 +3523,7 @@ def test_books_banned_non_book_admin
3468
3523
JSONAPI . configuration . top_level_meta_include_record_count = true
3469
3524
JSONAPI . configuration . json_key_format = :dasherized_key
3470
3525
3471
- assert_query_count ( through_primary ? ? 3 : 2 ) do
3526
+ assert_query_count ( testing_v10 ? ? 3 : 2 ) do
3472
3527
assert_cacheable_get :index , params : { page : { offset : 50 , limit : 12 } }
3473
3528
assert_response :success
3474
3529
assert_equal 12 , json_response [ 'data' ] . size
@@ -3485,7 +3540,19 @@ def test_books_banned_non_book_admin_includes_switched
3485
3540
3486
3541
Api ::V2 ::BookResource . paginator :offset
3487
3542
JSONAPI . configuration . top_level_meta_include_record_count = true
3488
- assert_query_count ( through_primary? ? 5 : 3 ) do
3543
+
3544
+ expected_count = case
3545
+ when testing_v09?
3546
+ 3
3547
+ when testing_v10?
3548
+ 5
3549
+ when through_primary?
3550
+ 4
3551
+ else
3552
+ 3
3553
+ end
3554
+
3555
+ assert_query_count ( expected_count ) do
3489
3556
assert_cacheable_get :index , params : { page : { offset : 0 , limit : 12 } , include : 'book-comments' }
3490
3557
assert_response :success
3491
3558
assert_equal 12 , json_response [ 'data' ] . size
@@ -3504,7 +3571,19 @@ def test_books_banned_non_book_admin_includes_nested_includes
3504
3571
JSONAPI . configuration . json_key_format = :dasherized_key
3505
3572
JSONAPI . configuration . top_level_meta_include_record_count = true
3506
3573
Api ::V2 ::BookResource . paginator :offset
3507
- assert_query_count ( through_primary? ? 7 : 4 ) do
3574
+
3575
+ expected_count = case
3576
+ when testing_v09?
3577
+ 4
3578
+ when testing_v10?
3579
+ 7
3580
+ when through_primary?
3581
+ 6
3582
+ else
3583
+ 4
3584
+ end
3585
+
3586
+ assert_query_count ( expected_count ) do
3508
3587
assert_cacheable_get :index , params : { page : { offset : 0 , limit : 12 } , include : 'book-comments.author' }
3509
3588
assert_response :success
3510
3589
assert_equal 12 , json_response [ 'data' ] . size
@@ -3522,7 +3601,7 @@ def test_books_banned_admin
3522
3601
Api ::V2 ::BookResource . paginator :offset
3523
3602
JSONAPI . configuration . json_key_format = :dasherized_key
3524
3603
JSONAPI . configuration . top_level_meta_include_record_count = true
3525
- assert_query_count ( through_primary ? ? 3 : 2 ) do
3604
+ assert_query_count ( testing_v10 ? ? 3 : 2 ) do
3526
3605
assert_cacheable_get :index , params : { page : { offset : 50 , limit : 12 } , filter : { banned : 'true' } }
3527
3606
end
3528
3607
assert_response :success
@@ -3539,7 +3618,7 @@ def test_books_not_banned_admin
3539
3618
Api ::V2 ::BookResource . paginator :offset
3540
3619
JSONAPI . configuration . json_key_format = :dasherized_key
3541
3620
JSONAPI . configuration . top_level_meta_include_record_count = true
3542
- assert_query_count ( through_primary ? ? 3 : 2 ) do
3621
+ assert_query_count ( testing_v10 ? ? 3 : 2 ) do
3543
3622
assert_cacheable_get :index , params : { page : { offset : 50 , limit : 12 } , filter : { banned : 'false' } , fields : { books : 'id,title' } }
3544
3623
end
3545
3624
assert_response :success
@@ -3557,7 +3636,7 @@ def test_books_banned_non_book_admin_overlapped
3557
3636
3558
3637
Api ::V2 ::BookResource . paginator :offset
3559
3638
JSONAPI . configuration . top_level_meta_include_record_count = true
3560
- assert_query_count ( through_primary ? ? 3 : 2 ) do
3639
+ assert_query_count ( testing_v10 ? ? 3 : 2 ) do
3561
3640
assert_cacheable_get :index , params : { page : { offset : 590 , limit : 20 } }
3562
3641
end
3563
3642
assert_response :success
@@ -3574,7 +3653,18 @@ def test_books_included_exclude_unapproved
3574
3653
with_jsonapi_config_changes do
3575
3654
JSONAPI . configuration . json_key_format = :dasherized_key
3576
3655
3577
- assert_query_count ( through_primary? ? 4 : 2 ) do
3656
+ expected_count = case
3657
+ when testing_v09?
3658
+ 2
3659
+ when testing_v10?
3660
+ 4
3661
+ when through_primary?
3662
+ 3
3663
+ else
3664
+ 2
3665
+ end
3666
+
3667
+ assert_query_count ( expected_count ) do
3578
3668
assert_cacheable_get :index , params : { filter : { id : '0,1,2,3,4' } , include : 'book-comments' }
3579
3669
end
3580
3670
assert_response :success
@@ -3695,7 +3785,7 @@ def setup
3695
3785
3696
3786
def test_book_comments_all_for_admin
3697
3787
$test_user = Person . find ( 1005 )
3698
- assert_query_count ( through_primary ? ? 2 : 1 ) do
3788
+ assert_query_count ( testing_v10 ? ? 2 : 1 ) do
3699
3789
assert_cacheable_get :index
3700
3790
end
3701
3791
assert_response :success
@@ -3704,7 +3794,7 @@ def test_book_comments_all_for_admin
3704
3794
3705
3795
def test_book_comments_unapproved_context_based
3706
3796
$test_user = Person . find ( 1005 )
3707
- assert_query_count ( through_primary ? ? 2 : 1 ) do
3797
+ assert_query_count ( testing_v10 ? ? 2 : 1 ) do
3708
3798
assert_cacheable_get :index , params : { filter : { approved : 'false' } }
3709
3799
end
3710
3800
assert_response :success
@@ -3713,7 +3803,7 @@ def test_book_comments_unapproved_context_based
3713
3803
3714
3804
def test_book_comments_exclude_unapproved_context_based
3715
3805
$test_user = Person . find ( 1001 )
3716
- assert_query_count ( through_primary ? ? 2 : 1 ) do
3806
+ assert_query_count ( testing_v10 ? ? 2 : 1 ) do
3717
3807
assert_cacheable_get :index
3718
3808
end
3719
3809
assert_response :success
0 commit comments