diff options
author | Joshua Peek <josh@joshpeek.com> | 2009-02-20 12:04:57 -0600 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2009-02-20 12:04:57 -0600 |
commit | 69c049f5ab45bf9bfb0d269acea0773581905fd4 (patch) | |
tree | f605c68ba9fae9ddfa77115ad0cef0da5a8ce770 /actionpack/test | |
parent | 53fe301a42f9d18b4a8a475e9babf64c621369ae (diff) | |
download | rails-69c049f5ab45bf9bfb0d269acea0773581905fd4.tar.gz rails-69c049f5ab45bf9bfb0d269acea0773581905fd4.tar.bz2 rails-69c049f5ab45bf9bfb0d269acea0773581905fd4.zip |
Move development mode reloading up the stack to avoid issues with class reloading in middleware
Diffstat (limited to 'actionpack/test')
-rw-r--r-- | actionpack/test/controller/dispatcher_test.rb | 13 |
1 files changed, 8 insertions, 5 deletions
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) |