Permalink
Browse files

Unit test that shows calling reset session twice results in an exception

  • Loading branch information...
1 parent 6c42c14 commit 589ce09564ad227fb07294d401c459b0620c42a9 @robdimarco robdimarco committed Mar 1, 2011
Showing with 44 additions and 0 deletions.
  1. +44 −0 actionpack/test/controller/session/cookie_store_test.rb
@@ -42,6 +42,12 @@ def call_session_clear
head :ok
end
+ def call_reset_session_twice
+ reset_session
+ reset_session
+ head :ok
+ end
+
def call_reset_session
reset_session
head :ok
@@ -190,6 +196,44 @@ def test_doesnt_write_session_cookie_if_session_is_unchanged
end
end
+ def test_calling_session_reset_twice
+ with_test_route_set do
+ get '/set_session_value'
+ assert_response :success
+ session_payload = response.body
+ assert_equal "_myapp_session=#{response.body}; path=/; HttpOnly",
+ headers['Set-Cookie']
+
+ get '/call_reset_session_twice'
+ assert_response :success
+ assert_not_equal "", headers['Set-Cookie']
+ assert_not_equal session_payload, cookies[SessionKey]
+
+ get '/get_session_value'
+ assert_response :success
+ assert_equal 'foo: nil', response.body
+ end
+ end
+
+ def test_setting_session_value_after_session_reset
+ with_test_route_set do
+ get '/set_session_value'
+ assert_response :success
+ session_payload = response.body
+ assert_equal "_myapp_session=#{response.body}; path=/; HttpOnly",
+ headers['Set-Cookie']
+
+ get '/call_reset_session'
+ assert_response :success
+ assert_not_equal "", headers['Set-Cookie']
+ assert_not_equal session_payload, cookies[SessionKey]
+
+ get '/get_session_value'
+ assert_response :success
+ assert_equal 'foo: nil', response.body
+ end
+ end
+
def test_setting_session_value_after_session_reset
with_test_route_set do
get '/set_session_value'

0 comments on commit 589ce09

Please sign in to comment.