mirror of https://github.com/rails/rails
Allow setting a default application for all integration tests
This commit is contained in:
parent
b0506b086f
commit
14866fa3d8
|
@ -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
|
||||
|
|
|
@ -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|
|
||||
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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue