aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--actionpack/lib/action_dispatch/testing/integration.rb22
-rw-r--r--actionpack/test/abstract_unit.rb12
-rw-r--r--actionpack/test/controller/dispatcher_test.rb3
3 files changed, 28 insertions, 9 deletions
diff --git a/actionpack/lib/action_dispatch/testing/integration.rb b/actionpack/lib/action_dispatch/testing/integration.rb
index 4c0d4455f9..f5dcea9158 100644
--- a/actionpack/lib/action_dispatch/testing/integration.rb
+++ b/actionpack/lib/action_dispatch/testing/integration.rb
@@ -325,6 +325,10 @@ module ActionDispatch
end
module Runner
+ def app
+ @app
+ end
+
# Reset the current session. This is useful for testing multiple sessions
# in a single test case.
def reset!
@@ -354,8 +358,7 @@ module ActionDispatch
# can use this method to open multiple sessions that ought to be tested
# simultaneously.
def open_session(app = nil)
- app ||= @app ||= ActionController::Dispatcher.new
- session = Integration::Session.new(app)
+ session = Integration::Session.new(app || self.app)
# delegate the fixture accessors back to the test instance
extras = Module.new { attr_accessor :delegate, :test_result }
@@ -477,5 +480,20 @@ module ActionDispatch
# end
class IntegrationTest < ActiveSupport::TestCase
include Integration::Runner
+
+ @@app = nil
+
+ def self.app
+ # DEPRECATE AC::Dispatcher fallback
+ @@app || ActionController::Dispatcher.new
+ end
+
+ def self.app=(app)
+ @@app = app
+ end
+
+ def app
+ super || self.class.app
+ end
end
end
diff --git a/actionpack/test/abstract_unit.rb b/actionpack/test/abstract_unit.rb
index 572a3d6fd9..aef3dd6165 100644
--- a/actionpack/test/abstract_unit.rb
+++ b/actionpack/test/abstract_unit.rb
@@ -52,11 +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"
+class ActionController::IntegrationTest < ActiveSupport::TestCase
+ @@app = ActionDispatch::MiddlewareStack.new { |middleware|
+ middleware.use "ActionDispatch::ShowExceptions"
+ middleware.use "ActionDispatch::Callbacks"
+ middleware.use "ActionDispatch::ParamsParser"
+ middleware.use "Rack::Head"
+ }.build(ActionController::Routing::Routes)
end
module ActionView
diff --git a/actionpack/test/controller/dispatcher_test.rb b/actionpack/test/controller/dispatcher_test.rb
index 8d974cb745..7ef2564e5a 100644
--- a/actionpack/test/controller/dispatcher_test.rb
+++ b/actionpack/test/controller/dispatcher_test.rb
@@ -22,7 +22,6 @@ class DispatcherTest < Test::Unit::TestCase
def teardown
Dispatcher.router = @old_router
- @dispatcher = nil
ENV.delete 'REQUEST_METHOD'
end
@@ -79,7 +78,7 @@ class DispatcherTest < Test::Unit::TestCase
ActionController::Dispatcher.prepare_each_request = false
Dispatcher.define_dispatcher_callbacks(cache_classes)
- @dispatcher ||= Dispatcher.new
+ @dispatcher ||= ActionDispatch::Callbacks.new(Dispatcher.router)
@dispatcher.call({'rack.input' => StringIO.new(''), 'action_dispatch.show_exceptions' => false})
end