Permalink
Browse files

Raise exceptions instead of rendering error templates in test environ…

…ment [#4315 state:resolved]

Signed-off-by: José Valim <jose.valim@gmail.com>
  • Loading branch information...
1 parent 13eb2c8 commit d898a4ba425a201827f07a5bb11c8c6bf85159b8 @rolfb rolfb committed with josevalim Apr 2, 2010
@@ -6,7 +6,8 @@ class Railtie < Rails::Railtie
config.action_dispatch = ActiveSupport::OrderedOptions.new
config.action_dispatch.x_sendfile_header = ""
config.action_dispatch.ip_spoofing_check = true
-
+ config.action_dispatch.show_exceptions = true
+
# Prepare dispatcher callbacks and run 'prepare' callbacks
initializer "action_dispatch.prepare_dispatcher" do |app|
# TODO: This used to say unless defined?(Dispatcher). Find out why and fix.
@@ -132,7 +132,7 @@ def default_middleware_stack
middleware.use('::Rack::Lock', :if => lambda { !allow_concurrency })
middleware.use('::Rack::Runtime')
middleware.use('::Rails::Rack::Logger')
- middleware.use('::ActionDispatch::ShowExceptions', lambda { consider_all_requests_local })
+ middleware.use('::ActionDispatch::ShowExceptions', lambda { consider_all_requests_local }, :if => lambda { action_dispatch.show_exceptions })
middleware.use("::ActionDispatch::RemoteIp", lambda { action_dispatch.ip_spoofing_check }, lambda { action_dispatch.trusted_proxies })
middleware.use('::Rack::Sendfile', lambda { action_dispatch.x_sendfile_header })
middleware.use('::ActionDispatch::Callbacks', lambda { !cache_classes })
@@ -14,6 +14,9 @@
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
+ # Raise exceptions instead of rendering exception templates
+ config.action_dispatch.show_exceptions = false
+
# Disable request forgery protection in test environment
config.action_controller.allow_forgery_protection = false

2 comments on commit d898a4b

Contributor

jnicklas commented on d898a4b Apr 3, 2010

Yay! I've been meaning to create an issue for this, great that it's fixed!

Contributor

huoxito replied Jan 14, 2016

been curious for a while but never bothered to ask, why the show_exceptions config default to false? doesn't it lead to confusing errors on assertions or even hide bugs if you don't do any assertion on the template rendered? I'm running tests on rspec / capybara, wonder if this is any different on minitest?

Please sign in to comment.