diff options
author | Neeraj Singh <neerajdotname@gmail.com> | 2010-06-08 11:59:09 -0400 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-07-19 14:50:38 +0200 |
commit | 33c5689e2d04aa08759903bc5d1e4de3bf6c35dd (patch) | |
tree | c8dd5917a8dd10017d7a653567ff084a5dfa18ab /actionpack/test/controller | |
parent | ad8f4dfc50fe3858b80aeceb6d9240d2af4a2fea (diff) | |
download | rails-33c5689e2d04aa08759903bc5d1e4de3bf6c35dd.tar.gz rails-33c5689e2d04aa08759903bc5d1e4de3bf6c35dd.tar.bz2 rails-33c5689e2d04aa08759903bc5d1e4de3bf6c35dd.zip |
Exceptions from views should be rescued based on the original exception. If a handler for original exception is missing then apply ActiveView::TemplateError
[#2034 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'actionpack/test/controller')
-rw-r--r-- | actionpack/test/controller/rescue_test.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/actionpack/test/controller/rescue_test.rb b/actionpack/test/controller/rescue_test.rb index 0f64b77647..a24de62b19 100644 --- a/actionpack/test/controller/rescue_test.rb +++ b/actionpack/test/controller/rescue_test.rb @@ -79,6 +79,14 @@ class RescueController < ActionController::Base render :text => 'no way' end + rescue_from ActionView::TemplateError do + render :text => 'action_view templater error' + end + + rescue_from IOError do + render :text => 'io error' + end + before_filter(:only => :before_filter_raises) { raise 'umm nice' } def before_filter_raises @@ -141,6 +149,14 @@ class RescueController < ActionController::Base def missing_template end + + def io_error_in_view + raise ActionView::TemplateError.new(nil, {}, IOError.new('this is io error')) + end + + def zero_division_error_in_view + raise ActionView::TemplateError.new(nil, {}, ZeroDivisionError.new('this is zero division error')) + end protected def deny_access @@ -228,6 +244,17 @@ class ControllerInheritanceRescueControllerTest < ActionController::TestCase end class RescueControllerTest < ActionController::TestCase + + def test_io_error_in_view + get :io_error_in_view + assert_equal 'io error', @response.body + end + + def test_zero_division_error_in_view + get :zero_division_error_in_view + assert_equal 'action_view templater error', @response.body + end + def test_rescue_handler get :not_authorized assert_response :forbidden |