Skip to content

Commit

Permalink
porting session.clear fix to master branch. [#5030 state:resolved]
Browse files Browse the repository at this point in the history
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
  • Loading branch information
tenderlove authored and jeremy committed Jul 1, 2010
1 parent 4a0c514 commit f8720a0
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
Expand Up @@ -64,6 +64,11 @@ def []=(key, value)
super(key.to_s, value)
end

def clear
load_for_write!
super
end

def to_hash
load_for_read!
h = {}.replace(self)
Expand Down
22 changes: 22 additions & 0 deletions actionpack/test/dispatch/session/cookie_store_test.rb
Expand Up @@ -30,6 +30,11 @@ def get_session_id
render :text => "id: #{request.session_options[:id]}"
end

def call_session_clear
session.clear
head :ok
end

def call_reset_session
reset_session
head :ok
Expand Down Expand Up @@ -175,6 +180,23 @@ def test_getting_from_nonexistent_session
end
end

def test_setting_session_value_after_session_clear
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_session_clear'
assert_response :success

get '/get_session_value'
assert_response :success
assert_equal 'foo: nil', response.body
end
end

def test_persistent_session_id
with_test_route_set do
cookies[SessionKey] = SignedBar
Expand Down

0 comments on commit f8720a0

Please sign in to comment.