This project is archived and is in readonly mode.
session is not preserved between requests in integration tests
-
epochwolf
The following test passes. (Using rails 2.3.8 and ruby 1.8.7)
require 'test_helper' class SessionTest < ActionController::IntegrationTest def test_session get "/home/index" s1 = @response.session[:session_id] get "/home/index" s2 = @response.session[:session_id] assert_equal s1, s2 end end -
Rohit Arondekar
- State changed from new to invalid
Thanks epochwolf. :)
Closing ticket, if this is still an issue for somebody please make a comment and I'll reopen.
-
Neeraj Singh
- State changed from invalid to open
I am able to reproduce it.
<"d265f9bd3feaf92460d4e4803913f114"> expected but was <"8a577f9faf4c0b2f5d1a5f07907b8c56">. class UsersController < ApplicationController def index session[:foo] = :bar @users = User.all end end require "#{File.dirname(__FILE__)}/../test_helper" class SessionTest < ActionController::IntegrationTest def test_session get "/" s1 = @response.session[:session_id] get "/" s2 = @response.session[:session_id] assert_equal s1, s2 end end -
Alex Farrill
Ruby versions where I observe this behavior:
ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0]
ruby 1.8.6 (2008-08-11 patchlevel 287) [universal-darwin9.7.0] Ruby Enterprise Edition 20090610 -
ronin-110977 (at lighthouseapp)
- Importance changed from to Low
We are running ruby 1.8.7 (2010-01-10 patchlevel 249) [i486-linux] with Rails 2.3.8 and we are having the same problems with the session not persisting in integration tests.
-
Teflon Ted
ditto here.
»ruby -v ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0] »rails -v Rails 2.3.8 -
birkirb
Same here, broke all integration tests that depend on sessions.
That's low priority? -
Pascal Friederich
I've added a patch which fixes the issue and also removes some code that has found its way into Rack in the meantime anyway. What it basically does is use Rack::Utils.set_cookie_header! to generate the Set-Cookie header and don't rely on manually constructing the header anymore. That also eliminates this ticket because set_cookie_header! already knows how to deal with header["Set-Cookie"] no matter if it's a String or an Array.
The patch is for 2-3-stable.
Note: if you are applying the patch, keep in mind that unfortunately the "stable" branch currently (with commit 0fcb4302e1a1193b2a59dd76abb436b24c93e3ac being the latest) is not as stable as you would expect it, because it has some failing test (already before applying my patch) which are unrelated to my patch ;-)
-
Pascal Friederich
- Title changed from session is not preserved between requests in integration tests to [PATCH] session is not preserved between requests in integration tests
-
Sebastian Röbke
- Assigned user set to Jeremy Kemper
- Tag changed from rails 2.3.8, integration_test, sessions to rails 2.3.8, 2.3.10, 2.3.9, 2.3.x, integration_test, sessions
Any chance to get this into 2.3.10?
-
Christian Seiler
same here
-
Jeff Kreeftmeijer
- Title changed from [PATCH] session is not preserved between requests in integration tests to session is not preserved between requests in integration tests
- Tag changed from rails 2.3.8, 2.3.10, 2.3.9, 2.3.x, integration_test, sessions to rails 2.3.8, 2.3.10, 2.3.9, 2.3.x, integration_test, patch, sessions
Using the "patch" tag instead of prefixing the ticket title with "[PATCH]" to make sure patched tickets end up in the open patches bin. :)
-
Ryan Bigg
- Tag changed from rails 2.3.8, 2, integration_test, patch, sessions to 2.3.10 2.3.9 2.3.x integration_test patch rails 2.3.8 sessions
Automatic cleanup of spam.
-
Andrea Campi
- Tag changed from 2.3.10 2.3.9 2.3.x integration_test patch rails 2.3.8 sessions to 2-3-stable, integration_test, paths, sessions
-
Karol Bucek
I've extracted some code from the provided patch that is usable as a workaround:
https://gist.github.com/646602
require 'integration_test_session_patch'in Your test_helper.rb -
Jan
I am having this or a similar issue with Rails 3.0.3 and ruby 1.8.7 (2008-08-11 patchlevel 72) [i686-darwin9].
Having your integration tests rendered useless is a killer for migrating our app to Rails 3. Priority low?!
-
Jan
Sorry. My problem was that I have set a cookie domain even in test, but did not set the host for my integration tests.
I guess, it's not related to this issue. The following helped:
def setup host! THE_HOST_EQUAL_TO_MY_SESSION_STORE_DOMAIN end -
Repository
- State changed from open to resolved
(from [e0eb8e9c65ededce64169948d4dd51b0079cdd10]) Let Rack::Utils.set_cookie_header! create the Set-Cookie header instead of manually fiddling with the response headers [#4941 session is not preserved between requests in integration tests state:resolved]
Signed-off-by: José Valim jose.valim@gmail.com
https://github.com/rails/rails/commit/e0eb8e9c65ededce64169948d4dd5...
