diff options
author | Joshua Peek <josh@joshpeek.com> | 2009-09-15 16:33:15 -0500 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2009-09-15 16:33:15 -0500 |
commit | 52aeb8d2e72223f9b40b0193c151c252a3f4fb09 (patch) | |
tree | 96ac7e1b9f0beafbc0dc51cea4070789d3b9980f /actionpack/test/controller/rescue_test.rb | |
parent | 90d7ae23c6f5a7e914d8b9fd74481ac61b6c4fb9 (diff) | |
download | rails-52aeb8d2e72223f9b40b0193c151c252a3f4fb09.tar.gz rails-52aeb8d2e72223f9b40b0193c151c252a3f4fb09.tar.bz2 rails-52aeb8d2e72223f9b40b0193c151c252a3f4fb09.zip |
Beef up AD::Rescue to replace global exception handling lost in ApplicationController
Diffstat (limited to 'actionpack/test/controller/rescue_test.rb')
-rw-r--r-- | actionpack/test/controller/rescue_test.rb | 35 |
1 files changed, 13 insertions, 22 deletions
diff --git a/actionpack/test/controller/rescue_test.rb b/actionpack/test/controller/rescue_test.rb index e8ca1ad0ee..09eddfe4a7 100644 --- a/actionpack/test/controller/rescue_test.rb +++ b/actionpack/test/controller/rescue_test.rb @@ -227,12 +227,6 @@ class ControllerInheritanceRescueControllerTest < ActionController::TestCase end end -class ApplicationController < ActionController::Base - rescue_from ActionController::RoutingError do - render :text => 'no way' - end -end - class RescueControllerTest < ActionController::TestCase def test_rescue_handler get :not_authorized @@ -331,24 +325,21 @@ class RescueTest < ActionController::IntegrationTest end end - # test 'rescue routing exceptions' do - # assert_equal 1, ApplicationController.rescue_handlers.length - # - # begin - # with_test_routing do - # get '/no_way' - # assert_equal 'no way', response.body - # end - # ensure - # ActionController::Base.rescue_handlers.clear - # end - # end + test 'rescue routing exceptions' do + app = ActionDispatch::Rescue.new(ActionController::Routing::Routes) do + rescue_from ActionController::RoutingError, lambda { |env| [200, {"Content-Type" => "text/html"}, "Gotcha!"] } + end + @integration_session = open_session(app) + + get '/b00m' + assert_equal "Gotcha!", response.body + end test 'unrescued exception' do - with_test_routing do - get '/b00m' - assert_match(/Action Controller: Exception caught/, response.body) - end + app = ActionDispatch::Rescue.new(ActionController::Routing::Routes) + @integration_session = open_session(app) + + assert_raise(ActionController::RoutingError) { get '/b00m' } end private |