Permalink
Browse files

Always use ActionDispatch::ShowExceptions middleware [#6462 state:res…

…olved]

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.
  • Loading branch information...
1 parent 439a745 commit 515ea955b6a80ab9f527ad0f6dcc25a17688a02c @sikachu sikachu committed with tenderlove Feb 22, 2011
View
2 railties/lib/rails/application.rb
@@ -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
View
37 railties/test/application/middleware/show_exceptions_test.rb
@@ -0,0 +1,37 @@
+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
View
4 railties/test/application/middleware_test.rb
@@ -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

0 comments on commit 515ea95

Please sign in to comment.