diff options
Diffstat (limited to 'actionpack')
4 files changed, 11 insertions, 19 deletions
diff --git a/actionpack/lib/action_controller/dispatch/dispatcher.rb b/actionpack/lib/action_controller/dispatch/dispatcher.rb index 75b778a676..e04da42637 100644 --- a/actionpack/lib/action_controller/dispatch/dispatcher.rb +++ b/actionpack/lib/action_controller/dispatch/dispatcher.rb @@ -7,12 +7,6 @@ module ActionController cattr_accessor :prepare_each_request self.prepare_each_request = false - cattr_accessor :router - self.router = Routing::Routes - - cattr_accessor :middleware - self.middleware = ActionDispatch::MiddlewareStack.new - class << self def define_dispatcher_callbacks(cache_classes) unless cache_classes @@ -21,7 +15,7 @@ module ActionController # Development mode callbacks ActionDispatch::Callbacks.before_dispatch do |app| - ActionController::Dispatcher.router.reload + ActionController::Routing::Routes.reload end ActionDispatch::Callbacks.after_dispatch do @@ -55,7 +49,8 @@ module ActionController :to => ActionDispatch::Callbacks def new - @@middleware.build(@@router) + # DEPRECATE Rails application fallback + Rails.application end end end diff --git a/actionpack/lib/action_controller/testing/process.rb b/actionpack/lib/action_controller/testing/process.rb index fd368a7d79..bbc7f3c8f9 100644 --- a/actionpack/lib/action_controller/testing/process.rb +++ b/actionpack/lib/action_controller/testing/process.rb @@ -99,7 +99,6 @@ module ActionController #:nodoc: temporary_routes = ActionController::Routing::RouteSet.new ActionController::Routing.module_eval { const_set :Routes, temporary_routes } - ActionController::Dispatcher.router = temporary_routes yield temporary_routes ensure @@ -107,7 +106,6 @@ module ActionController #:nodoc: ActionController::Routing.module_eval { remove_const :Routes } end ActionController::Routing.const_set(:Routes, real_routes) if real_routes - ActionController::Dispatcher.router = ActionController::Routing::Routes end end end diff --git a/actionpack/lib/action_dispatch/testing/integration.rb b/actionpack/lib/action_dispatch/testing/integration.rb index f5dcea9158..9f7877fa46 100644 --- a/actionpack/lib/action_dispatch/testing/integration.rb +++ b/actionpack/lib/action_dispatch/testing/integration.rb @@ -484,8 +484,9 @@ module ActionDispatch @@app = nil def self.app - # DEPRECATE AC::Dispatcher fallback - @@app || ActionController::Dispatcher.new + # DEPRECATE Rails application fallback + # This should be set by the initializer + @@app || (defined?(Rails.application) && Rails.application) || nil end def self.app=(app) diff --git a/actionpack/test/controller/dispatcher_test.rb b/actionpack/test/controller/dispatcher_test.rb index 7ef2564e5a..622d67287d 100644 --- a/actionpack/test/controller/dispatcher_test.rb +++ b/actionpack/test/controller/dispatcher_test.rb @@ -14,14 +14,12 @@ class DispatcherTest < Test::Unit::TestCase ActionDispatch::Callbacks.reset_callbacks(:prepare) ActionDispatch::Callbacks.reset_callbacks(:call) - @old_router, Dispatcher.router = Dispatcher.router, mock() - Dispatcher.router.stubs(:call).returns([200, {}, 'response']) - Dispatcher.router.stubs(:reload) + ActionController::Routing::Routes.stubs(:call).returns([200, {}, 'response']) + ActionController::Routing::Routes.stubs(:reload) Dispatcher.stubs(:require_dependency) end def teardown - Dispatcher.router = @old_router ENV.delete 'REQUEST_METHOD' end @@ -31,12 +29,12 @@ class DispatcherTest < Test::Unit::TestCase end def test_reloads_routes_before_dispatch_if_in_loading_mode - Dispatcher.router.expects(:reload).once + ActionController::Routing::Routes.expects(:reload).once dispatch(false) end def test_leaves_dependencies_after_dispatch_if_not_in_loading_mode - Dispatcher.router.expects(:reload).never + ActionController::Routing::Routes.expects(:reload).never ActiveSupport::Dependencies.expects(:clear).never dispatch @@ -78,7 +76,7 @@ class DispatcherTest < Test::Unit::TestCase ActionController::Dispatcher.prepare_each_request = false Dispatcher.define_dispatcher_callbacks(cache_classes) - @dispatcher ||= ActionDispatch::Callbacks.new(Dispatcher.router) + @dispatcher ||= ActionDispatch::Callbacks.new(ActionController::Routing::Routes) @dispatcher.call({'rack.input' => StringIO.new(''), 'action_dispatch.show_exceptions' => false}) end |