diff --git a/actionpack/test/controller/session/cookie_store_test.rb b/actionpack/test/controller/session/cookie_store_test.rb index 40fcd56..2d11f35 100644 --- a/actionpack/test/controller/session/cookie_store_test.rb +++ b/actionpack/test/controller/session/cookie_store_test.rb @@ -39,6 +39,17 @@ class CookieStoreTest < ActionController::IntegrationTest head :ok end + def get_session_id_after_reset_session + reset_session + render :text => request.session_options[:id] + end + + def set_session_value_after_reset_session + reset_session + session[:foo] = "bar" + head :ok + end + def raise_data_overflow session[:foo] = 'bye!' * 1024 head :ok @@ -124,6 +135,37 @@ class CookieStoreTest < ActionController::IntegrationTest end end + def test_session_id_is_available_immediately_after_reset_session + with_test_route_set do + cookies[SessionKey] = SignedBar + get '/get_session_id_after_reset_session' + assert_response :success + assert_not_equal "", response.body + end + end + + def test_session_id_is_different_immediately_after_reset_session + with_test_route_set do + cookies[SessionKey] = SignedBar + get '/persistent_session_id' + session_id = response.body + get '/get_session_id_after_reset_session' + assert_response :success + assert_not_equal session_id, response.body + end + end + + def test_session_is_usable_immediately_after_reset_session + with_test_route_set do + cookies[SessionKey] = SignedBar + get '/set_session_value_after_reset_session' + assert_response :success + get '/get_session_value' + assert_response :success + assert_equal 'foo: "bar"', response.body + end + end + def test_disregards_tampered_sessions with_test_route_set do cookies[SessionKey] = "BAh7BjoIZm9vIghiYXI%3D--123456780" diff --git a/actionpack/test/controller/session/mem_cache_store_test.rb b/actionpack/test/controller/session/mem_cache_store_test.rb index 2f80a3c..d0965f8 100644 --- a/actionpack/test/controller/session/mem_cache_store_test.rb +++ b/actionpack/test/controller/session/mem_cache_store_test.rb @@ -28,6 +28,17 @@ class MemCacheStoreTest < ActionController::IntegrationTest head :ok end + def get_session_id_after_reset_session + reset_session + render :text => request.session_options[:id] + end + + def set_session_value_after_reset_session + reset_session + session[:foo] = "bar" + head :ok + end + def rescue_action(e) raise end end @@ -109,6 +120,35 @@ class MemCacheStoreTest < ActionController::IntegrationTest assert_equal nil, cookies['_session_id'] end end + + def test_session_id_is_available_immediately_after_reset_session + with_test_route_set do + get '/get_session_id_after_reset_session' + assert_response :success + assert_not_equal "", response.body + end + end + + def test_session_id_is_different_immediately_after_reset_session + with_test_route_set do + get '/persistent_session_id' + session_id = response.body + get '/get_session_id_after_reset_session' + assert_response :success + assert_not_equal session_id, response.body + end + end + + def test_session_is_usable_immediately_after_reset_session + with_test_route_set do + get '/set_session_value_after_reset_session' + assert_response :success + get '/get_session_value' + assert_response :success + assert_equal 'foo: "bar"', response.body + end + end + rescue LoadError, RuntimeError $stderr.puts "Skipping MemCacheStoreTest tests. Start memcached and try again." end