aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller/dispatcher_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/test/controller/dispatcher_test.rb')
-rw-r--r--actionpack/test/controller/dispatcher_test.rb13
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)