diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2008-12-30 18:06:56 -0800 |
---|---|---|
committer | Yehuda Katz <wycats@gmail.com> | 2009-01-01 00:13:11 -0800 |
commit | 658cf556d2bf3ea099fbce434ca338bf28365b40 (patch) | |
tree | 9eea2baef4356b4d2a0b11c0006d4c760a7dae8c /actionpack | |
parent | 6b3c702bd7321e7fcf86a82edb720b96a7e34119 (diff) | |
download | rails-658cf556d2bf3ea099fbce434ca338bf28365b40.tar.gz rails-658cf556d2bf3ea099fbce434ca338bf28365b40.tar.bz2 rails-658cf556d2bf3ea099fbce434ca338bf28365b40.zip |
Test that exceptions raised in filters are properly rescued
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_controller/base.rb | 11 | ||||
-rw-r--r-- | actionpack/test/controller/rescue_test.rb | 15 |
2 files changed, 22 insertions, 4 deletions
diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb index bc18dfaec8..aa604395a9 100644 --- a/actionpack/lib/action_controller/base.rb +++ b/actionpack/lib/action_controller/base.rb @@ -1350,9 +1350,12 @@ module ActionController #:nodoc: end Base.class_eval do - include Flash, Filters, Layout, Benchmarking, Rescue, MimeResponds, Helpers - include Cookies, Caching, Verification, Streaming - include SessionManagement, HttpAuthentication::Basic::ControllerMethods - include RecordIdentifier, RequestForgeryProtection, Translation + [ Flash, Filters, Layout, Benchmarking, Rescue, MimeResponds, Helpers, + Cookies, Caching, Verification, Streaming, SessionManagement, + HttpAuthentication::Basic::ControllerMethods, RecordIdentifier, + RequestForgeryProtection, Translation + ].each do |mod| + include mod + end end end diff --git a/actionpack/test/controller/rescue_test.rb b/actionpack/test/controller/rescue_test.rb index 49aca3a6ee..d45ba3c3a1 100644 --- a/actionpack/test/controller/rescue_test.rb +++ b/actionpack/test/controller/rescue_test.rb @@ -67,6 +67,11 @@ class RescueController < ActionController::Base render :text => 'no way' end + before_filter(:only => :before_filter_raises) { raise 'umm nice' } + + def before_filter_raises + end + def raises render :text => 'already rendered' raise "don't panic!" @@ -154,6 +159,16 @@ class RescueControllerTest < ActionController::TestCase end end + def test_rescue_exceptions_raised_by_filters + with_rails_root FIXTURE_PUBLIC do + with_all_requests_local false do + get :before_filter_raises + end + end + + assert_response :internal_server_error + end + def test_rescue_action_locally_if_all_requests_local @controller.expects(:local_request?).never @controller.expects(:rescue_action_locally).with(@exception) |