From 69c049f5ab45bf9bfb0d269acea0773581905fd4 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Fri, 20 Feb 2009 12:04:57 -0600 Subject: Move development mode reloading up the stack to avoid issues with class reloading in middleware --- actionpack/test/controller/dispatcher_test.rb | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'actionpack/test') diff --git a/actionpack/test/controller/dispatcher_test.rb b/actionpack/test/controller/dispatcher_test.rb index 47226f1fc5..7887b7110c 100644 --- a/actionpack/test/controller/dispatcher_test.rb +++ b/actionpack/test/controller/dispatcher_test.rb @@ -6,14 +6,17 @@ class DispatcherTest < Test::Unit::TestCase def setup ENV['REQUEST_METHOD'] = 'GET' + Dispatcher.middleware = ActionController::MiddlewareStack.new do |middleware| + middlewares = File.expand_path(File.join(File.dirname(__FILE__), "../../lib/action_controller/middlewares.rb")) + middleware.instance_eval(File.read(middlewares)) + end + # Clear callbacks as they are redefined by Dispatcher#define_dispatcher_callbacks Dispatcher.instance_variable_set("@prepare_dispatch_callbacks", ActiveSupport::Callbacks::CallbackChain.new) Dispatcher.instance_variable_set("@before_dispatch_callbacks", ActiveSupport::Callbacks::CallbackChain.new) Dispatcher.instance_variable_set("@after_dispatch_callbacks", ActiveSupport::Callbacks::CallbackChain.new) Dispatcher.stubs(:require_dependency) - - @dispatcher = Dispatcher.new end def teardown @@ -65,7 +68,7 @@ class DispatcherTest < Test::Unit::TestCase assert_nil a || b || c # Run callbacks - @dispatcher.send :run_callbacks, :prepare_dispatch + Dispatcher.run_prepare_callbacks assert_equal 1, a assert_equal 2, b @@ -82,7 +85,7 @@ class DispatcherTest < Test::Unit::TestCase Dispatcher.to_prepare(:unique_id) { |*args| a = b = 1 } Dispatcher.to_prepare(:unique_id) { |*args| a = 2 } - @dispatcher.send :run_callbacks, :prepare_dispatch + Dispatcher.run_prepare_callbacks assert_equal 2, a assert_equal nil, b end @@ -91,7 +94,7 @@ class DispatcherTest < Test::Unit::TestCase def dispatch(cache_classes = true) ActionController::Routing::RouteSet.any_instance.stubs(:call).returns([200, {}, 'response']) Dispatcher.define_dispatcher_callbacks(cache_classes) - @dispatcher.call({}) + Dispatcher.new.call({}) end def assert_subclasses(howmany, klass, message = klass.subclasses.inspect) -- cgit v1.2.3