Permalink
Browse files

Fix AbstractStore so that it preserves Set-Cookie header as an array,…

… rather than as newline separated strings
  • Loading branch information...
1 parent bdfddb0 commit 36b91e34f493a52bece1193b85b01aa89a813061 @omarqureshi omarqureshi committed with tenderlove Oct 11, 2010
@@ -206,11 +206,8 @@ def call(env)
cookie << "; HttpOnly" if options[:httponly]
headers = response[1]
- unless headers[SET_COOKIE].blank?
- headers[SET_COOKIE] << "\n#{cookie}"
- else
- headers[SET_COOKIE] = cookie
- end
+ headers[SET_COOKIE] = [] if headers[SET_COOKIE].blank?
+ headers[SET_COOKIE] << cookie
end
end
@@ -31,6 +31,12 @@ def call_reset_session
session[:foo] = "baz"
head :ok
end
+
+ def set_session_value_and_cookie
+ cookies["foo"] = "bar"
+ session[:foo] = "bar"
+ render :nothing => true
+ end
def rescue_action(e) raise end
end
@@ -194,6 +200,15 @@ def test_allows_session_fixation
assert_equal session_id, cookies['_session_id']
end
end
+
+ def test_setting_session_value_and_cookie
+ with_test_route_set do
+ get '/set_session_value_and_cookie'
+ assert_response :success
+ assert !cookies["\n_session_id"]
+ assert_equal({"_session_id" => request.session_options[:id], "foo" => "bar"}, cookies)
+ end
+ end
private
def with_test_route_set

3 comments on commit 36b91e3

@paukul
paukul commented on 36b91e3 Dec 1, 2010

As described in https://rails.lighthouseapp.com/projects/8994/tickets/4941-session-is-not-preserved-between-requests-in-integration-tests#ticket-4941-10
there's patch for that which removes the duplication of code and bugs in the session store with a call to Rack::Utils.set_cookie_header! (fixing by adding code vs. by removing code). Imho paukul@0dbdbb2 would be a much cleaner solution because a method for that task already present in Rack and should be utilized here

@josevalim
Member

paukul I have applied your fix.

@paukul
paukul commented on 36b91e3 Dec 1, 2010

sweet! :)

Please sign in to comment.