aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--actionpack/lib/action_controller/dispatch/dispatcher.rb11
-rw-r--r--actionpack/lib/action_controller/testing/process.rb2
-rw-r--r--actionpack/lib/action_dispatch/testing/integration.rb5
-rw-r--r--actionpack/test/controller/dispatcher_test.rb12
-rw-r--r--railties/lib/rails/application.rb6
-rw-r--r--railties/lib/rails/console_app.rb2
-rw-r--r--railties/lib/rails/initializer.rb2
-rw-r--r--railties/test/console_app_test.rb6
-rw-r--r--railties/test/fcgi_dispatcher_test.rb6
9 files changed, 30 insertions, 22 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
diff --git a/railties/lib/rails/application.rb b/railties/lib/rails/application.rb
index d3057aaa11..14336d90c3 100644
--- a/railties/lib/rails/application.rb
+++ b/railties/lib/rails/application.rb
@@ -1,10 +1,14 @@
module Rails
class Application
+ attr_accessor :middleware, :routes
+
def initialize
- @app = ActionController::Dispatcher.new
+ @middleware = ActionDispatch::MiddlewareStack.new
+ @routes = ActionController::Routing::Routes
end
def call(env)
+ @app ||= middleware.build(@routes)
@app.call(env)
end
end
diff --git a/railties/lib/rails/console_app.rb b/railties/lib/rails/console_app.rb
index fc84a50e91..1ad62e5058 100644
--- a/railties/lib/rails/console_app.rb
+++ b/railties/lib/rails/console_app.rb
@@ -27,6 +27,6 @@ end
def reload!
puts "Reloading..."
ActionDispatch::Callbacks.new(lambda {}, true)
- ActionController::Dispatcher.router.reload
+ ActionController::Routing::Routes.reload
true
end
diff --git a/railties/lib/rails/initializer.rb b/railties/lib/rails/initializer.rb
index 399ce26618..f6aca082e8 100644
--- a/railties/lib/rails/initializer.rb
+++ b/railties/lib/rails/initializer.rb
@@ -608,8 +608,8 @@ Run `rake gems:install` to install the missing gems.
Initializer.default.add :build_application do
if configuration.frameworks.include?(:action_controller)
- ActionController::Dispatcher.middleware = configuration.middleware
Rails.application = Rails::Application.new
+ Rails.application.middleware = configuration.middleware
end
end
end
diff --git a/railties/test/console_app_test.rb b/railties/test/console_app_test.rb
index 7d697d4d05..1437e6d885 100644
--- a/railties/test/console_app_test.rb
+++ b/railties/test/console_app_test.rb
@@ -5,6 +5,12 @@ require 'action_controller' # console_app uses 'action_controller/integration'
require 'rails/dispatcher'
require 'rails/console_app'
+module Rails
+ def self.application
+ ActionController::Routing::Routes
+ end
+end
+
# console_app sets Test::Unit.run to work around the at_exit hook in test/unit, which kills IRB
if Test::Unit.respond_to?(:run=)
Test::Unit.run = false
diff --git a/railties/test/fcgi_dispatcher_test.rb b/railties/test/fcgi_dispatcher_test.rb
index 1e704b862f..4d77a321a0 100644
--- a/railties/test/fcgi_dispatcher_test.rb
+++ b/railties/test/fcgi_dispatcher_test.rb
@@ -5,6 +5,12 @@ uses_gem "fcgi", "0.8.7" do
require 'action_controller'
require 'rails/fcgi_handler'
+module Rails
+ def self.application
+ ActionController::Routing::Routes
+ end
+end
+
class RailsFCGIHandlerTest < Test::Unit::TestCase
def setup
@log = StringIO.new