From 14866fa3d83676d340d94464f50e2e0ea989c3c1 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Sat, 26 Sep 2009 21:38:48 -0500 Subject: Allow setting a default application for all integration tests --- .../lib/action_dispatch/testing/integration.rb | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'actionpack/lib/action_dispatch/testing/integration.rb') 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 -- cgit v1.2.3