diff options
-rw-r--r-- | actionpack/lib/action_controller/dispatch/dispatcher.rb | 5 | ||||
-rw-r--r-- | actionpack/lib/action_controller/dispatch/middlewares.rb | 16 | ||||
-rw-r--r-- | actionpack/test/abstract_unit.rb | 13 | ||||
-rw-r--r-- | actionpack/test/controller/dispatcher_test.rb | 4 | ||||
-rw-r--r-- | actionpack/test/dispatch/session/cookie_store_test.rb | 3 | ||||
-rw-r--r-- | railties/lib/rails/console_app.rb | 2 | ||||
-rw-r--r-- | railties/lib/rails/initializer.rb | 14 | ||||
-rw-r--r-- | railties/test/console_app_test.rb | 5 |
8 files changed, 22 insertions, 40 deletions
diff --git a/actionpack/lib/action_controller/dispatch/dispatcher.rb b/actionpack/lib/action_controller/dispatch/dispatcher.rb index ba316b9e63..75b778a676 100644 --- a/actionpack/lib/action_controller/dispatch/dispatcher.rb +++ b/actionpack/lib/action_controller/dispatch/dispatcher.rb @@ -11,10 +11,7 @@ module ActionController self.router = Routing::Routes cattr_accessor :middleware - self.middleware = ActionDispatch::MiddlewareStack.new do |middleware| - middlewares = File.join(File.dirname(__FILE__), "middlewares.rb") - middleware.instance_eval(File.read(middlewares), middlewares, 1) - end + self.middleware = ActionDispatch::MiddlewareStack.new class << self def define_dispatcher_callbacks(cache_classes) diff --git a/actionpack/lib/action_controller/dispatch/middlewares.rb b/actionpack/lib/action_controller/dispatch/middlewares.rb deleted file mode 100644 index 5641b3cb8d..0000000000 --- a/actionpack/lib/action_controller/dispatch/middlewares.rb +++ /dev/null @@ -1,16 +0,0 @@ -use "Rack::Lock", :if => lambda { - !ActionController::Base.allow_concurrency -} - -use "ActionDispatch::ShowExceptions", lambda { ActionController::Base.consider_all_requests_local } -use "ActionDispatch::Callbacks", lambda { ActionController::Dispatcher.prepare_each_request } - -# TODO: Redirect global exceptions somewhere? -# use "ActionDispatch::Rescue" - -use lambda { ActionController::Base.session_store }, - lambda { ActionController::Base.session_options } - -use "ActionDispatch::ParamsParser" -use "Rack::MethodOverride" -use "Rack::Head" diff --git a/actionpack/test/abstract_unit.rb b/actionpack/test/abstract_unit.rb index c54efa308c..572a3d6fd9 100644 --- a/actionpack/test/abstract_unit.rb +++ b/actionpack/test/abstract_unit.rb @@ -52,6 +52,13 @@ ORIGINAL_LOCALES = I18n.available_locales.map {|locale| locale.to_s }.sort FIXTURE_LOAD_PATH = File.join(File.dirname(__FILE__), 'fixtures') +ActionController::Dispatcher.middleware = ActionDispatch::MiddlewareStack.new do |middleware| + middleware.use "ActionDispatch::ShowExceptions" + middleware.use "ActionDispatch::Callbacks" + middleware.use "ActionDispatch::ParamsParser" + middleware.use "Rack::Head" +end + module ActionView class TestCase setup do @@ -114,12 +121,6 @@ class ::ApplicationController < ActionController::Base end module ActionController - Base.session = { - :key => '_testing_session', - :secret => '8273f16463985e2b3747dc25e30f2528' - } - Base.session_store = nil - class << Routing def possible_controllers @@possible_controllers ||= [] diff --git a/actionpack/test/controller/dispatcher_test.rb b/actionpack/test/controller/dispatcher_test.rb index 150fc83cde..39e6f7d273 100644 --- a/actionpack/test/controller/dispatcher_test.rb +++ b/actionpack/test/controller/dispatcher_test.rb @@ -83,10 +83,6 @@ class DispatcherTest < Test::Unit::TestCase def dispatch(cache_classes = true) ActionController::Dispatcher.prepare_each_request = false Dispatcher.define_dispatcher_callbacks(cache_classes) - Dispatcher.middleware = ActionDispatch::MiddlewareStack.new do |middleware| - middlewares = File.expand_path(File.join(File.dirname(__FILE__), "../../lib/action_controller/dispatch/middlewares.rb")) - middleware.instance_eval(File.read(middlewares)) - end @dispatcher ||= Dispatcher.new @dispatcher.call({'rack.input' => StringIO.new(''), 'action_dispatch.show_exceptions' => false}) diff --git a/actionpack/test/dispatch/session/cookie_store_test.rb b/actionpack/test/dispatch/session/cookie_store_test.rb index 366a14168b..bc0b4b22a5 100644 --- a/actionpack/test/dispatch/session/cookie_store_test.rb +++ b/actionpack/test/dispatch/session/cookie_store_test.rb @@ -5,9 +5,6 @@ class CookieStoreTest < ActionController::IntegrationTest SessionKey = '_myapp_session' SessionSecret = 'b3c631c314c0bbca50c1b2843150fe33' - # Make sure Session middleware doesnt get included in the middleware stack - ActionController::Base.session_store = nil - Verifier = ActiveSupport::MessageVerifier.new(SessionSecret, 'SHA1') SignedBar = Verifier.generate(:foo => "bar", :session_id => ActiveSupport::SecureRandom.hex(16)) diff --git a/railties/lib/rails/console_app.rb b/railties/lib/rails/console_app.rb index 75e6f11ea3..5ce3d0d13b 100644 --- a/railties/lib/rails/console_app.rb +++ b/railties/lib/rails/console_app.rb @@ -25,7 +25,7 @@ end #reloads the environment def reload! puts "Reloading..." - ActionController::Dispatcher.new + ActionDispatch::Callbacks.new(lambda {}, true) ActionController::Dispatcher.router.reload true end diff --git a/railties/lib/rails/initializer.rb b/railties/lib/rails/initializer.rb index 72d23f2642..d05cb69ffe 100644 --- a/railties/lib/rails/initializer.rb +++ b/railties/lib/rails/initializer.rb @@ -272,7 +272,19 @@ module Rails # Include middleware to serve up static assets Initializer.default.add :initialize_static_server do if configuration.frameworks.include?(:action_controller) && configuration.serve_static_assets - configuration.middleware.insert(0, ActionDispatch::Static, Rails.public_path) + configuration.middleware.use(ActionDispatch::Static, Rails.public_path) + end + end + + Initializer.default.add :initialize_middleware_stack do + if configuration.frameworks.include?(:action_controller) + configuration.middleware.use(::Rack::Lock) unless ActionController::Base.allow_concurrency + configuration.middleware.use(ActionDispatch::ShowExceptions, ActionController::Base.consider_all_requests_local) + configuration.middleware.use(ActionDispatch::Callbacks, ActionController::Dispatcher.prepare_each_request) + configuration.middleware.use(lambda { ActionController::Base.session_store }, lambda { ActionController::Base.session_options }) + configuration.middleware.use(ActionDispatch::ParamsParser) + configuration.middleware.use(::Rack::MethodOverride) + configuration.middleware.use(::Rack::Head) end end diff --git a/railties/test/console_app_test.rb b/railties/test/console_app_test.rb index a26a8895ec..d2512a4987 100644 --- a/railties/test/console_app_test.rb +++ b/railties/test/console_app_test.rb @@ -2,11 +2,6 @@ require 'abstract_unit' require 'action_controller' # console_app uses 'action_controller/integration' -unless defined? ApplicationController - class ApplicationController < ActionController::Base; end - ActionController::Base.session_store = nil -end - require 'rails/dispatcher' require 'rails/console_app' |