rails/railties/test/rails_health_controller_test.rb
Sam Ruby 50cb28ac9f
add "as: :rails_health_check" to health check path (#47217)
This makes the path discoverable even if the name or even the
controller action changes.

Co-authored-by: David Heinemeier Hansson <dhh@hey.com>
2023-02-05 08:49:04 +01:00

32 lines
786 B
Ruby

# frozen_string_literal: true
require "abstract_unit"
class HealthControllerTest < ActionController::TestCase
tests Rails::HealthController
def setup
Rails.application.routes.draw do
get "/up" => "rails/health#show", as: :rails_health_check
end
@routes = Rails.application.routes
end
test "health controller renders green success page" do
get :show
assert_response :success
assert_match(/background-color: green/, @response.body)
end
test "health controller renders red internal server error page" do
@controller.instance_eval do
def render_up
raise Exception, "some exception"
end
end
get :show
assert_response :internal_server_error
assert_match(/background-color: red/, @response.body)
end
end