From 9c9da6c892d715ca22c3cf51f50deb1d80029c66 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Thu, 4 Dec 2008 20:39:36 -0600 Subject: Boot out CGI Processor. * Add ActionController::CGIHandler as a backwards compatible CGI wrapper around Rack. * Also pull failsafe responder into ActionController::Failsafe middleware. --- actionpack/test/controller/dispatcher_test.rb | 38 +++++++++++++-------------- 1 file changed, 18 insertions(+), 20 deletions(-) (limited to 'actionpack/test/controller/dispatcher_test.rb') diff --git a/actionpack/test/controller/dispatcher_test.rb b/actionpack/test/controller/dispatcher_test.rb index 61bfb2b6e9..30dda87bb4 100644 --- a/actionpack/test/controller/dispatcher_test.rb +++ b/actionpack/test/controller/dispatcher_test.rb @@ -6,7 +6,6 @@ class DispatcherTest < Test::Unit::TestCase Dispatcher = ActionController::Dispatcher def setup - @output = StringIO.new ENV['REQUEST_METHOD'] = 'GET' # Clear callbacks as they are redefined by Dispatcher#define_dispatcher_callbacks @@ -16,7 +15,7 @@ class DispatcherTest < Test::Unit::TestCase Dispatcher.stubs(:require_dependency) - @dispatcher = Dispatcher.new(@output) + @dispatcher = Dispatcher.new end def teardown @@ -25,17 +24,17 @@ class DispatcherTest < Test::Unit::TestCase def test_clears_dependencies_after_dispatch_if_in_loading_mode ActiveSupport::Dependencies.expects(:clear).once - dispatch(@output, false) + dispatch(false) end def test_reloads_routes_before_dispatch_if_in_loading_mode ActionController::Routing::Routes.expects(:reload).once - dispatch(@output, false) + dispatch(false) end def test_clears_asset_tag_cache_before_dispatch_if_in_loading_mode ActionView::Helpers::AssetTagHelper::AssetTag::Cache.expects(:clear).once - dispatch(@output, false) + dispatch(false) end def test_leaves_dependencies_after_dispatch_if_not_in_loading_mode @@ -51,12 +50,16 @@ class DispatcherTest < Test::Unit::TestCase end def test_failsafe_response - CGI.expects(:new).raises('some multipart parsing failure') - Dispatcher.expects(:log_failsafe_exception) - - assert_nothing_raised { dispatch } - - assert_equal "Status: 400 Bad Request\r\nContent-Type: text/html\r\n\r\n

400 Bad Request

", @output.string + Dispatcher.any_instance.expects(:dispatch_unlocked).raises('b00m') + ActionController::Failsafe.any_instance.expects(:log_failsafe_exception) + + assert_nothing_raised do + assert_equal [ + 500, + {"Content-Type" => "text/html"}, + "

500 Internal Server Error

" + ], dispatch + end end def test_prepare_callbacks @@ -77,7 +80,7 @@ class DispatcherTest < Test::Unit::TestCase # Make sure they are only run once a = b = c = nil - @dispatcher.send :dispatch + dispatch assert_nil a || b || c end @@ -92,15 +95,10 @@ class DispatcherTest < Test::Unit::TestCase end private - def dispatch(output = @output, cache_classes = true) - controller = mock - controller.stubs(:process).returns(controller) - controller.stubs(:out).with(output).returns('response') - - ActionController::Routing::Routes.stubs(:recognize).returns(controller) - + def dispatch(cache_classes = true) + Dispatcher.any_instance.stubs(:handle_request).returns([200, {}, 'response']) Dispatcher.define_dispatcher_callbacks(cache_classes) - Dispatcher.dispatch(nil, {}, output) + @dispatcher.call({}) end def assert_subclasses(howmany, klass, message = klass.subclasses.inspect) -- cgit v1.2.3