aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller/filters_test.rb
diff options
context:
space:
mode:
authorTobias Lütke <tobias.luetke@gmail.com>2007-05-22 19:17:43 +0000
committerTobias Lütke <tobias.luetke@gmail.com>2007-05-22 19:17:43 +0000
commit19fbd84e126e77fccafbca06d3b8e9723de492cb (patch)
treef58f367d1c71445616b70162979c9b35111cf644 /actionpack/test/controller/filters_test.rb
parent4611d0e1081713821053006061616d2baeb3e3ee (diff)
downloadrails-19fbd84e126e77fccafbca06d3b8e9723de492cb.tar.gz
rails-19fbd84e126e77fccafbca06d3b8e9723de492cb.tar.bz2
rails-19fbd84e126e77fccafbca06d3b8e9723de492cb.zip
Rescuing in around_filters works as expected again [codahale, Stephan Kaes]. Closes #8341
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6810 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/test/controller/filters_test.rb')
-rw-r--r--actionpack/test/controller/filters_test.rb35
1 files changed, 35 insertions, 0 deletions
diff --git a/actionpack/test/controller/filters_test.rb b/actionpack/test/controller/filters_test.rb
index e84661b688..a38e55fb52 100644
--- a/actionpack/test/controller/filters_test.rb
+++ b/actionpack/test/controller/filters_test.rb
@@ -324,6 +324,31 @@ class FilterTest < Test::Unit::TestCase
render :text => 'hello'
end
end
+
+ class ErrorToRescue < Exception; end
+
+ class RescuingAroundFilterWithBlock
+ def filter(controller)
+ begin
+ yield
+ rescue ErrorToRescue => ex
+ controller.send :render, :text => "I rescued this: #{ex.inspect}"
+ end
+ end
+ end
+
+ class RescuedController < ActionController::Base
+ around_filter RescuingAroundFilterWithBlock.new
+
+ def show
+ raise ErrorToRescue.new("Something made the bad noise.")
+ end
+
+ private
+ def rescue_action(exception)
+ raise exception
+ end
+ end
def test_empty_filter_chain
assert_equal 0, EmptyFilterChainController.filter_chain.size
@@ -491,6 +516,16 @@ class FilterTest < Test::Unit::TestCase
def test_changing_the_requirements
assert_equal nil, test_process(ChangingTheRequirementsController, "go_wild").template.assigns['ran_filter']
end
+
+ def test_a_rescuing_around_filter
+ response = nil
+ assert_nothing_raised do
+ response = test_process(RescuedController)
+ end
+
+ assert response.success?
+ assert_equal("I rescued this: #<FilterTest::ErrorToRescue: Something made the bad noise.>", response.body)
+ end
private
def test_process(controller, action = "show")