提交 515ea955 编写于 作者: P Prem Sichanugrist 提交者: Aaron Patterson

Always use ActionDispatch::ShowExceptions middleware [#6462 state:resolved]

This will make sure the application will raise `ActionController::RoutingError` in case "X-Cascade: pass" header was set, usually when there's no route match.
上级 439a7452
......@@ -157,7 +157,7 @@ def default_middleware_stack
middleware.use ::Rack::Lock unless config.allow_concurrency
middleware.use ::Rack::Runtime
middleware.use ::Rails::Rack::Logger
middleware.use ::ActionDispatch::ShowExceptions, config.consider_all_requests_local if config.action_dispatch.show_exceptions
middleware.use ::ActionDispatch::ShowExceptions, config.consider_all_requests_local
middleware.use ::ActionDispatch::RemoteIp, config.action_dispatch.ip_spoofing_check, config.action_dispatch.trusted_proxies
middleware.use ::Rack::Sendfile, config.action_dispatch.x_sendfile_header
middleware.use ::ActionDispatch::Reloader unless config.cache_classes
......
require 'isolation/abstract_unit'
module ApplicationTests
class ShowExceptionsTest < Test::Unit::TestCase
include ActiveSupport::Testing::Isolation
def setup
build_app
boot_rails
FileUtils.rm_rf "#{app_path}/config/environments"
end
def app
@app ||= Rails.application
end
test "unspecified route when set action_dispatch.show_exceptions to false" do
make_basic_app do |app|
app.config.action_dispatch.show_exceptions = false
end
assert_raise(ActionController::RoutingError) do
get '/foo'
end
end
test "unspecified route when set action_dispatch.show_exceptions to true" do
make_basic_app do |app|
app.config.action_dispatch.show_exceptions = true
end
assert_nothing_raised(ActionController::RoutingError) do
get '/foo'
end
end
end
end
......@@ -78,10 +78,10 @@ def app
assert !middleware.include?("ActionDispatch::Static")
end
test "removes show exceptions if action_dispatch.show_exceptions is disabled" do
test "includes show exceptions even action_dispatch.show_exceptions is disabled" do
add_to_config "config.action_dispatch.show_exceptions = false"
boot!
assert !middleware.include?("ActionDispatch::ShowExceptions")
assert middleware.include?("ActionDispatch::ShowExceptions")
end
test "removes ActionDispatch::Reloader if cache_classes is true" do
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册