@@ -296,15 +296,37 @@ def test_index_filter_not_allowed
296296 end
297297
298298 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
300311 assert_cacheable_get :index , params : { include : 'author' }
301312 end
302313
303314 assert_response :success
304315 end
305316
306317 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
308330 assert_cacheable_get :index , params : { include : 'author,author.comments' }
309331 end
310332 assert_response :success
@@ -355,7 +377,7 @@ def test_index_filter_by_ids_and_fields_2
355377 end
356378
357379 def test_filter_relationship_single
358- assert_query_count ( through_primary ? ? 2 : 1 ) do
380+ assert_query_count ( testing_v10 ? ? 2 : 1 ) do
359381 assert_cacheable_get :index , params : { filter : { tags : '505,501' } }
360382 end
361383 assert_response :success
@@ -366,7 +388,7 @@ def test_filter_relationship_single
366388 end
367389
368390 def test_filter_relationships_multiple
369- assert_query_count ( through_primary ? ? 2 : 1 ) do
391+ assert_query_count ( testing_v10 ? ? 2 : 1 ) do
370392 assert_cacheable_get :index , params : { filter : { tags : '505,501' , comments : '3' } }
371393 end
372394 assert_response :success
@@ -3303,7 +3325,18 @@ def test_books_offset_pagination_no_params_includes_query_count_one_level
33033325
33043326 with_jsonapi_config_changes do
33053327 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
33073340 assert_cacheable_get :index , params : { include : 'book-comments' }
33083341 end
33093342 assert_response :success
@@ -3317,7 +3350,18 @@ def test_books_offset_pagination_no_params_includes_query_count_two_levels
33173350 with_jsonapi_config_changes do
33183351 JSONAPI . configuration . json_key_format = :dasherized_key
33193352
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
33213365 assert_cacheable_get :index , params : { include : 'book-comments,book-comments.author' }
33223366 end
33233367 assert_response :success
@@ -3451,7 +3495,18 @@ def test_books_included_paged
34513495
34523496 with_jsonapi_config_changes do
34533497 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
34553510 assert_cacheable_get :index , params : { filter : { id : '0' } , include : 'book-comments' }
34563511 assert_response :success
34573512 assert_equal 1 , json_response [ 'data' ] . size
@@ -3468,7 +3523,7 @@ def test_books_banned_non_book_admin
34683523 JSONAPI . configuration . top_level_meta_include_record_count = true
34693524 JSONAPI . configuration . json_key_format = :dasherized_key
34703525
3471- assert_query_count ( through_primary ? ? 3 : 2 ) do
3526+ assert_query_count ( testing_v10 ? ? 3 : 2 ) do
34723527 assert_cacheable_get :index , params : { page : { offset : 50 , limit : 12 } }
34733528 assert_response :success
34743529 assert_equal 12 , json_response [ 'data' ] . size
@@ -3485,7 +3540,19 @@ def test_books_banned_non_book_admin_includes_switched
34853540
34863541 Api ::V2 ::BookResource . paginator :offset
34873542 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
34893556 assert_cacheable_get :index , params : { page : { offset : 0 , limit : 12 } , include : 'book-comments' }
34903557 assert_response :success
34913558 assert_equal 12 , json_response [ 'data' ] . size
@@ -3504,7 +3571,19 @@ def test_books_banned_non_book_admin_includes_nested_includes
35043571 JSONAPI . configuration . json_key_format = :dasherized_key
35053572 JSONAPI . configuration . top_level_meta_include_record_count = true
35063573 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
35083587 assert_cacheable_get :index , params : { page : { offset : 0 , limit : 12 } , include : 'book-comments.author' }
35093588 assert_response :success
35103589 assert_equal 12 , json_response [ 'data' ] . size
@@ -3522,7 +3601,7 @@ def test_books_banned_admin
35223601 Api ::V2 ::BookResource . paginator :offset
35233602 JSONAPI . configuration . json_key_format = :dasherized_key
35243603 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
35263605 assert_cacheable_get :index , params : { page : { offset : 50 , limit : 12 } , filter : { banned : 'true' } }
35273606 end
35283607 assert_response :success
@@ -3539,7 +3618,7 @@ def test_books_not_banned_admin
35393618 Api ::V2 ::BookResource . paginator :offset
35403619 JSONAPI . configuration . json_key_format = :dasherized_key
35413620 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
35433622 assert_cacheable_get :index , params : { page : { offset : 50 , limit : 12 } , filter : { banned : 'false' } , fields : { books : 'id,title' } }
35443623 end
35453624 assert_response :success
@@ -3557,7 +3636,7 @@ def test_books_banned_non_book_admin_overlapped
35573636
35583637 Api ::V2 ::BookResource . paginator :offset
35593638 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
35613640 assert_cacheable_get :index , params : { page : { offset : 590 , limit : 20 } }
35623641 end
35633642 assert_response :success
@@ -3574,7 +3653,18 @@ def test_books_included_exclude_unapproved
35743653 with_jsonapi_config_changes do
35753654 JSONAPI . configuration . json_key_format = :dasherized_key
35763655
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
35783668 assert_cacheable_get :index , params : { filter : { id : '0,1,2,3,4' } , include : 'book-comments' }
35793669 end
35803670 assert_response :success
@@ -3695,7 +3785,7 @@ def setup
36953785
36963786 def test_book_comments_all_for_admin
36973787 $test_user = Person . find ( 1005 )
3698- assert_query_count ( through_primary ? ? 2 : 1 ) do
3788+ assert_query_count ( testing_v10 ? ? 2 : 1 ) do
36993789 assert_cacheable_get :index
37003790 end
37013791 assert_response :success
@@ -3704,7 +3794,7 @@ def test_book_comments_all_for_admin
37043794
37053795 def test_book_comments_unapproved_context_based
37063796 $test_user = Person . find ( 1005 )
3707- assert_query_count ( through_primary ? ? 2 : 1 ) do
3797+ assert_query_count ( testing_v10 ? ? 2 : 1 ) do
37083798 assert_cacheable_get :index , params : { filter : { approved : 'false' } }
37093799 end
37103800 assert_response :success
@@ -3713,7 +3803,7 @@ def test_book_comments_unapproved_context_based
37133803
37143804 def test_book_comments_exclude_unapproved_context_based
37153805 $test_user = Person . find ( 1001 )
3716- assert_query_count ( through_primary ? ? 2 : 1 ) do
3806+ assert_query_count ( testing_v10 ? ? 2 : 1 ) do
37173807 assert_cacheable_get :index
37183808 end
37193809 assert_response :success
0 commit comments