@@ -4215,8 +4215,15 @@ def test_complex_includes_things_nested_things
42154215 assert_cacheable_get :index , params : { include : 'things,things.things,things.things.things' }
42164216
42174217 assert_response :success
4218- assert_hash_equals (
4219- {
4218+ sorted_json_response_data = json_response [ "data" ]
4219+ . sort_by { |data | Integer ( data [ "id" ] ) }
4220+ sorted_json_response_included = json_response [ "included" ]
4221+ . sort_by { |included | "#{ included [ 'type' ] } -#{ Integer ( included [ 'id' ] ) } " }
4222+ sorted_json_response = {
4223+ "data" => sorted_json_response_data ,
4224+ "included" => sorted_json_response_included ,
4225+ }
4226+ expected = {
42204227 "data" => [
42214228 {
42224229 "id" => "100" ,
@@ -4471,15 +4478,23 @@ def test_complex_includes_things_nested_things
44714478 }
44724479 }
44734480 ]
4474- } ,
4475- json_response )
4481+ }
4482+ assert_hash_equals ( expected_response , sorted_json_response )
44764483 end
44774484
44784485 def test_complex_includes_nested_things_secondary_users
44794486 assert_cacheable_get :index , params : { include : 'things,things.user,things.things' }
44804487
44814488 assert_response :success
4482- assert_hash_equals (
4489+ sorted_json_response_data = json_response [ "data" ]
4490+ . sort_by { |data | Integer ( data [ "id" ] ) }
4491+ sorted_json_response_included = json_response [ "included" ]
4492+ . sort_by { |included | "#{ included [ 'type' ] } -#{ Integer ( included [ 'id' ] ) } " }
4493+ sorted_json_response = {
4494+ "data" => sorted_json_response_data ,
4495+ "included" => sorted_json_response_included ,
4496+ }
4497+ expected =
44834498 {
44844499 "data" => [
44854500 {
@@ -4766,8 +4781,8 @@ def test_complex_includes_nested_things_secondary_users
47664781 }
47674782 }
47684783 ]
4769- } ,
4770- json_response )
4784+ }
4785+ assert_hash_equals ( expected , sorted_json_response )
47714786 end
47724787end
47734788
@@ -4810,7 +4825,10 @@ def test_fetch_robots_with_sort_by_name
48104825 . all
48114826 . order ( name : :asc )
48124827 . map ( &:name )
4813- assert_equal expected_names . first , json_response [ 'data' ] . first [ 'attributes' ] [ 'name' ] , "since adapter_sorts_nulls_last=#{ adapter_sorts_nulls_last } "
4828+ actual_names = json_response [ 'data' ] . map { |data |
4829+ data [ 'attributes' ] [ 'name' ]
4830+ }
4831+ assert_equal expected_names , actual_names , "since adapter_sorts_nulls_last=#{ adapter_sorts_nulls_last } "
48144832 end
48154833
48164834 def test_fetch_robots_with_sort_by_lower_name
0 commit comments