aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoreileencodes <eileencodes@gmail.com>2015-03-09 16:43:49 -0400
committereileencodes <eileencodes@gmail.com>2015-03-09 17:11:15 -0400
commit2e4a01b92ca2165442c130071bd19af52d14d7cf (patch)
treeb0e814b18ac0de0e259b602334a39fc4cb8d4b49
parentd5e55e960c2919ad71ea645d219677457e9832eb (diff)
downloadrails-2e4a01b92ca2165442c130071bd19af52d14d7cf.tar.gz
rails-2e4a01b92ca2165442c130071bd19af52d14d7cf.tar.bz2
rails-2e4a01b92ca2165442c130071bd19af52d14d7cf.zip
Call super last in before_setup
This fixes the reasons 4cf3b8a, 303567e, and fa63448 needed to be reverted in 7142059. The revert has been reverted and this fixes the issues caused previously. If we call `super` first we will end up nuking the session settings in the application tests that do `setup do` - so any session login or cookie settings will not be persisted thoughout the test sessions. Calling `super` last prevents `@integration_session` from getting nuked and set to nil if it's already set. Test added to prevent regression of this behavior in the future.
-rw-r--r--actionpack/lib/action_dispatch/testing/integration.rb2
-rw-r--r--actionpack/test/controller/integration_test.rb12
2 files changed, 13 insertions, 1 deletions
diff --git a/actionpack/lib/action_dispatch/testing/integration.rb b/actionpack/lib/action_dispatch/testing/integration.rb
index faf62fcd1d..9390e2937a 100644
--- a/actionpack/lib/action_dispatch/testing/integration.rb
+++ b/actionpack/lib/action_dispatch/testing/integration.rb
@@ -391,9 +391,9 @@ module ActionDispatch
attr_reader :app
def before_setup
- super
@app = nil
@integration_session = nil
+ super
end
def integration_session
diff --git a/actionpack/test/controller/integration_test.rb b/actionpack/test/controller/integration_test.rb
index 438c044da2..9504914dba 100644
--- a/actionpack/test/controller/integration_test.rb
+++ b/actionpack/test/controller/integration_test.rb
@@ -1036,3 +1036,15 @@ class IntegrationRequestsWithoutSetup < ActionDispatch::IntegrationTest
end
end
end
+
+# to ensure that session requirements in setup are persisted in the tests
+class IntegrationRequestsWithSessionSetup < ActionDispatch::IntegrationTest
+ setup do
+ cookies['user_name'] = 'david'
+ end
+
+ def test_cookies_set_in_setup_are_persisted_through_the_session
+ get "/foo"
+ assert_equal({"user_name"=>"david"}, cookies.to_hash)
+ end
+end