Skip to content

Commit

Permalink
Fix integration test problems.
Browse files Browse the repository at this point in the history
  • Loading branch information
gregschmit committed Dec 15, 2024
1 parent c81462e commit f3dffc0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
Expand Down
13 changes: 8 additions & 5 deletions test/test/integration/api/demo_routing_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 6 additions & 3 deletions test/test/integration/rescuing_unknown_formats_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit f3dffc0

Please sign in to comment.