Set session options id to nil is respected and cancels lazy loading.

This commit is contained in:
José Valim
2010-07-18 12:51:03 +02:00
parent cdfa11409c
commit 291adcd588
2 changed files with 21 additions and 3 deletions

View File

@@ -24,9 +24,9 @@ module ActionDispatch
def [](key)
if key == :id
load_session_id! unless super(:id) || has_session_id?
load_session_id! unless key?(:id) || has_session_id?
end
super(key)
super
end
private

View File

@@ -44,7 +44,12 @@ class CookieStoreTest < ActionController::IntegrationTest
session[:foo] = 'bye!' * 1024
head :ok
end
def change_session_id
request.session_options[:id] = nil
get_session_id
end
def rescue_action(e) raise end
end
@@ -212,6 +217,19 @@ class CookieStoreTest < ActionController::IntegrationTest
end
end
def test_setting_session_id_to_nil_is_respected
with_test_route_set do
cookies[SessionKey] = SignedBar
get "/get_session_id"
sid = response.body
assert_equal sid.size, 36
get "/change_session_id"
assert_not_equal sid, response.body
end
end
def test_session_store_with_expire_after
with_test_route_set(:expire_after => 5.hours) do
# First request accesses the session