Permalink
Browse files

CookieStore should preserve the Set-Cookie header Array [#4743 state:…

…resolved]

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
  • Loading branch information...
1 parent 5ed6a84 commit 85b6d79d8a17fdef667770e31b44ac6647f8b584 @jstorimer jstorimer committed with jeremy Jun 1, 2010
@@ -114,11 +114,8 @@ def call(env)
end
cookie = build_cookie(@key, cookie.merge(options))
- unless headers[HTTP_SET_COOKIE].blank?
- headers[HTTP_SET_COOKIE] << "\n#{cookie}"
- else
- headers[HTTP_SET_COOKIE] = cookie
- end
+ headers[HTTP_SET_COOKIE] = [] if headers[HTTP_SET_COOKIE].blank?
+ headers[HTTP_SET_COOKIE] << cookie
end
[status, headers, body]
@@ -44,6 +44,12 @@ def raise_data_overflow
head :ok
end
+ def set_session_value_and_cookie
+ cookies["foo"] = "bar"
+ session[:foo] = "bar"
+ render :text => Rack::Utils.escape(Verifier.generate(session.to_hash))
+ end
+
def rescue_action(e) raise end
end
@@ -96,7 +102,7 @@ def test_setting_session_value
with_test_route_set do
get '/set_session_value'
assert_response :success
- assert_equal "_myapp_session=#{response.body}; path=/; HttpOnly",
+ assert_equal ["_myapp_session=#{response.body}; path=/; HttpOnly"],
headers['Set-Cookie']
end
end
@@ -164,7 +170,7 @@ def test_setting_session_value_after_session_reset
get '/set_session_value'
assert_response :success
session_payload = response.body
- assert_equal "_myapp_session=#{response.body}; path=/; HttpOnly",
+ assert_equal ["_myapp_session=#{response.body}; path=/; HttpOnly"],
headers['Set-Cookie']
get '/call_reset_session'
@@ -193,6 +199,14 @@ def test_persistent_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_equal({"_myapp_session" => response.body, "foo" => "bar"}, cookies)
+ end
+ end
+
private
def with_test_route_set
with_routing do |set|

0 comments on commit 85b6d79

Please sign in to comment.