From f3dffc0722958a75450565be5c1849ad50a1e511 Mon Sep 17 00:00:00 2001 From: "Gregory N. Schmit" Date: Sat, 14 Dec 2024 23:12:51 -0600 Subject: [PATCH] Fix integration test problems. --- .../users_controller_test.rb | 1 - test/test/integration/api/demo_routing_test.rb | 13 ++++++++----- .../integration/rescuing_unknown_formats_test.rb | 9 ++++++--- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/test/test/controllers/api/test/active_model_serializer/users_controller_test.rb b/test/test/controllers/api/test/active_model_serializer/users_controller_test.rb index 9d5ecf6..95beac0 100644 --- a/test/test/controllers/api/test/active_model_serializer/users_controller_test.rb +++ b/test/test/controllers/api/test/active_model_serializer/users_controller_test.rb @@ -6,7 +6,6 @@ def test_list User.create!(login: "test", manager_attributes: {login: "test2"}) get(:index, as: :json) assert_response(:success) - puts @response.parsed_body assert(@response.parsed_body[1]["login"]) assert(@response.parsed_body[1]["manager"]) assert_equal("working!", @response.parsed_body[1]["test_serializer_method"]) diff --git a/test/test/integration/api/demo_routing_test.rb b/test/test/integration/api/demo_routing_test.rb index 845252f..9d70f9b 100644 --- a/test/test/integration/api/demo_routing_test.rb +++ b/test/test/integration/api/demo_routing_test.rb @@ -16,10 +16,13 @@ def test_can_get_users assert_response(:success) end - def test_can_not_get_network_resourceful_routes - get("/api/demo/network.json") - assert_response(:not_found) - get("/api/demo/network") - assert_response(:not_found) + # Only Rails>=8 due to changes in integration test behavior. + if Rails::VERSION::MAJOR >= 8 + def test_can_not_get_network_resourceful_routes + get("/api/demo/network.json") + assert_response(:not_found) + get("/api/demo/network") + assert_response(:not_found) + end end end diff --git a/test/test/integration/rescuing_unknown_formats_test.rb b/test/test/integration/rescuing_unknown_formats_test.rb index 9622fcd..6946da4 100644 --- a/test/test/integration/rescuing_unknown_formats_test.rb +++ b/test/test/integration/rescuing_unknown_formats_test.rb @@ -3,9 +3,12 @@ # The goal of this test is to ensure unknown formats are rescued, when configured. class RescuingUnknownFormatsTest < ActionDispatch::IntegrationTest # Test that an invalid format raises an uncaught exception. - def test_raise_unknown_format - get("/api/test/no_rescue_unknown_format.jsom") - assert_response(:not_acceptable) + # Only Rails >=8 due to changes in integration test behavior. + if Rails::VERSION::MAJOR >= 8 + def test_raise_unknown_format + get("/api/test/no_rescue_unknown_format.jsom") + assert_response(:not_acceptable) + end end # Test that we rescue an unknown format and also that it defaults to :json.