diff options
author | Bryan Helmkamp <bryan@brynary.com> | 2009-05-16 14:15:26 -0400 |
---|---|---|
committer | Bryan Helmkamp <bryan@brynary.com> | 2009-05-16 14:15:26 -0400 |
commit | 7f318c3ec535afe53733c55cd0ecaccc16a8b944 (patch) | |
tree | 405f8e828b0d0f0d5eecb28ac844308beec19cf6 /actionpack | |
parent | a6d8ca0f0e65ce509793713cb1efe4ab721b9eb4 (diff) | |
download | rails-7f318c3ec535afe53733c55cd0ecaccc16a8b944.tar.gz rails-7f318c3ec535afe53733c55cd0ecaccc16a8b944.tar.bz2 rails-7f318c3ec535afe53733c55cd0ecaccc16a8b944.zip |
Instead of checking Rails.env.test? in Failsafe middleware, check env["rails.raise_exceptions"]
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_dispatch/middleware/failsafe.rb | 5 | ||||
-rw-r--r-- | actionpack/test/new_base/render_action_test.rb | 6 | ||||
-rw-r--r-- | actionpack/test/new_base/render_test.rb | 6 |
3 files changed, 9 insertions, 8 deletions
diff --git a/actionpack/lib/action_dispatch/middleware/failsafe.rb b/actionpack/lib/action_dispatch/middleware/failsafe.rb index 836098482c..389accbc36 100644 --- a/actionpack/lib/action_dispatch/middleware/failsafe.rb +++ b/actionpack/lib/action_dispatch/middleware/failsafe.rb @@ -10,9 +10,8 @@ module ActionDispatch def call(env) @app.call(env) rescue Exception => exception - # Reraise exception in test environment - if defined?(Rails) && Rails.env.test? - raise exception + if env["rails.raise_exceptions"] + raise else failsafe_response(exception) end diff --git a/actionpack/test/new_base/render_action_test.rb b/actionpack/test/new_base/render_action_test.rb index f25faee433..96666077d2 100644 --- a/actionpack/test/new_base/render_action_test.rb +++ b/actionpack/test/new_base/render_action_test.rb @@ -92,7 +92,7 @@ module RenderAction test "raises an exception when requesting a layout and none exist" do assert_raise(ArgumentError, /no default layout for RenderAction::BasicController in/) do - get "/render_action/basic/hello_world_with_layout" + get "/render_action/basic/hello_world_with_layout", {}, "rails.raise_exceptions" => true end end end @@ -117,7 +117,9 @@ module RenderAction describe "rendering a normal template with full path with layout => 'greetings'" test "raises an exception when requesting a layout that does not exist" do - assert_raise(ActionView::MissingTemplate) { get "/render_action/basic/hello_world_with_custom_layout" } + assert_raise(ActionView::MissingTemplate) do + get "/render_action/basic/hello_world_with_custom_layout", {}, "rails.raise_exceptions" => true + end end end diff --git a/actionpack/test/new_base/render_test.rb b/actionpack/test/new_base/render_test.rb index b1867fdcc2..16578fbc82 100644 --- a/actionpack/test/new_base/render_test.rb +++ b/actionpack/test/new_base/render_test.rb @@ -48,7 +48,7 @@ module Render test "raises an exception" do assert_raises(AbstractController::DoubleRenderError) do - get "/render/double_render" + get "/render/double_render", {}, "rails.raise_exceptions" => true end end end @@ -58,13 +58,13 @@ module Render test "raises an exception when a method of Object is called" do assert_raises(AbstractController::ActionNotFound) do - get "/render/blank_render/clone" + get "/render/blank_render/clone", {}, "rails.raise_exceptions" => true end end test "raises an exception when a private method is called" do assert_raises(AbstractController::ActionNotFound) do - get "/render/blank_render/secretz" + get "/render/blank_render/secretz", {}, "rails.raise_exceptions" => true end end end |