1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Revert integration test refactoring that caused app test regressions

Haven't diagnosed yet. No similarly failing tests in Rails to work from.

cc @tenderlove, @eileencodes

Revert "there is always an integration session, so remove the check"
Revert "lazily create the integration session"
Revert "use before_setup to set up test instance variables"

This reverts commits 4cf3b8ac47, 303567e554, and fa63448420.
This commit is contained in:
Jeremy Kemper 2015-02-26 17:55:59 -07:00
parent a13e52b422
commit 7142059883
2 changed files with 18 additions and 10 deletions

View file

@ -388,16 +388,8 @@ module ActionDispatch
APP_SESSIONS = {} APP_SESSIONS = {}
attr_reader :app def app
@app ||= nil
def before_setup
super
@app = nil
@integration_session = nil
end
def integration_session
@integration_session ||= create_session(app)
end end
# Reset the current session. This is useful for testing multiple sessions # Reset the current session. This is useful for testing multiple sessions
@ -425,6 +417,8 @@ module ActionDispatch
%w(get post patch put head delete cookies assigns %w(get post patch put head delete cookies assigns
xml_http_request xhr get_via_redirect post_via_redirect).each do |method| xml_http_request xhr get_via_redirect post_via_redirect).each do |method|
define_method(method) do |*args| define_method(method) do |*args|
reset! unless integration_session
# reset the html_document variable, except for cookies/assigns calls # reset the html_document variable, except for cookies/assigns calls
unless method == 'cookies' || method == 'assigns' unless method == 'cookies' || method == 'assigns'
@html_document = nil @html_document = nil
@ -456,16 +450,19 @@ module ActionDispatch
# Copy the instance variables from the current session instance into the # Copy the instance variables from the current session instance into the
# test instance. # test instance.
def copy_session_variables! #:nodoc: def copy_session_variables! #:nodoc:
return unless integration_session
@controller = @integration_session.controller @controller = @integration_session.controller
@response = @integration_session.response @response = @integration_session.response
@request = @integration_session.request @request = @integration_session.request
end end
def default_url_options def default_url_options
reset! unless integration_session
integration_session.default_url_options integration_session.default_url_options
end end
def default_url_options=(options) def default_url_options=(options)
reset! unless integration_session
integration_session.default_url_options = options integration_session.default_url_options = options
end end
@ -475,6 +472,7 @@ module ActionDispatch
# Delegate unhandled messages to the current session instance. # Delegate unhandled messages to the current session instance.
def method_missing(sym, *args, &block) def method_missing(sym, *args, &block)
reset! unless integration_session
if integration_session.respond_to?(sym) if integration_session.respond_to?(sym)
integration_session.__send__(sym, *args, &block).tap do integration_session.__send__(sym, *args, &block).tap do
copy_session_variables! copy_session_variables!
@ -483,6 +481,11 @@ module ActionDispatch
super super
end end
end end
private
def integration_session
@integration_session ||= nil
end
end end
end end
@ -659,6 +662,7 @@ module ActionDispatch
end end
def url_options def url_options
reset! unless integration_session
integration_session.url_options integration_session.url_options
end end

View file

@ -254,6 +254,10 @@ class ResponseTest < ActiveSupport::TestCase
end end
class ResponseIntegrationTest < ActionDispatch::IntegrationTest class ResponseIntegrationTest < ActionDispatch::IntegrationTest
def app
@app
end
test "response cache control from railsish app" do test "response cache control from railsish app" do
@app = lambda { |env| @app = lambda { |env|
ActionDispatch::Response.new.tap { |resp| ActionDispatch::Response.new.tap { |resp|