Skip to content

Commit

Permalink
Raise exceptions instead of rendering error templates in test environ…
Browse files Browse the repository at this point in the history
…ment [#4315 state:resolved]

Signed-off-by: José Valim <jose.valim@gmail.com>
  • Loading branch information
rolfb authored and josevalim committed Apr 2, 2010
1 parent 13eb2c8 commit d898a4b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion actionpack/lib/action_dispatch/railtie.rb
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion railties/lib/rails/application/configuration.rb
Expand Up @@ -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 })
Expand Down
Expand Up @@ -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

Expand Down

2 comments on commit d898a4b

@jnicklas
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@huoxito
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.