Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Instead of checking Rails.env.test? in Failsafe middleware, check env…

…["rails.raise_exceptions"]
  • Loading branch information...
commit 7f318c3ec535afe53733c55cd0ecaccc16a8b944 1 parent a6d8ca0
@brynary brynary authored
View
5 actionpack/lib/action_dispatch/middleware/failsafe.rb
@@ -10,9 +10,8 @@ def initialize(app)
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
View
6 actionpack/test/new_base/render_action_test.rb
@@ -92,7 +92,7 @@ class TestLayoutTrue < SimpleRouteCase
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 @@ class TestCustomLayout < SimpleRouteCase
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
View
6 actionpack/test/new_base/render_test.rb
@@ -48,7 +48,7 @@ class TestBasic < SimpleRouteCase
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 @@ class TestOnlyRenderPublicActions < SimpleRouteCase
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

3 comments on commit 7f318c3

@josh
Collaborator

Instead of the rails namespace, use the proper component. So it would be "action_dispatch" in this case.

@josh
Collaborator

Cools,

BTW, I'm probably going merge Failsafe and ShowExceptions. They are pretty much doing the same thing now. But this same api will still work.

Please sign in to comment.
Something went wrong with that request. Please try again.