diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2007-02-25 16:35:24 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2007-02-25 16:35:24 +0000 |
commit | 781985f7f229eb665b3eed693eb9642caebc44a0 (patch) | |
tree | b87cd67949c03e89af269652622a73589d027224 /actionpack/test/controller/session | |
parent | c9770d8a5ac1c477943ba431396e5d7e6b7389b0 (diff) | |
download | rails-781985f7f229eb665b3eed693eb9642caebc44a0.tar.gz rails-781985f7f229eb665b3eed693eb9642caebc44a0.tar.bz2 rails-781985f7f229eb665b3eed693eb9642caebc44a0.zip |
Cookie session store: empty and unchanged sessions don't write a cookie.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6226 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/test/controller/session')
-rwxr-xr-x | actionpack/test/controller/session/cookie_store_test.rb | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/actionpack/test/controller/session/cookie_store_test.rb b/actionpack/test/controller/session/cookie_store_test.rb index 7a12fb4650..353785825b 100755 --- a/actionpack/test/controller/session/cookie_store_test.rb +++ b/actionpack/test/controller/session/cookie_store_test.rb @@ -68,11 +68,20 @@ class CookieStoreTest < Test::Unit::TestCase end end + def test_close_doesnt_write_cookie_if_data_is_blank + new_session do |session| + assert_nil session.cgi.output_cookies, session.cgi.output_cookies.inspect + session.close + assert_nil session.cgi.output_cookies, session.cgi.output_cookies.inspect + end + end + def test_close_doesnt_write_cookie_if_data_is_unchanged set_cookie! Cookies::TYPICAL.first new_session do |session| assert_nil session.cgi.output_cookies, session.cgi.output_cookies.inspect session['user_id'] = session['user_id'] + session.close assert_nil session.cgi.output_cookies, session.cgi.output_cookies.inspect end end @@ -91,7 +100,7 @@ class CookieStoreTest < Test::Unit::TestCase end end - def test_delete_writes_expired_empty_cookie + def test_delete_writes_expired_empty_cookie_and_sets_data_to_nil set_cookie! Cookies::TYPICAL.first new_session do |session| assert_nil session.cgi.output_cookies, session.cgi.output_cookies.inspect @@ -100,6 +109,11 @@ class CookieStoreTest < Test::Unit::TestCase cookie = session.cgi.output_cookies.first assert_equal ['_myapp_session', [], 1.year.ago.to_date], [cookie.name, cookie.value, cookie.expires.to_date] + + # @data is set to nil so #close doesn't send another cookie. + session.close + assert_equal ['_myapp_session', [], 1.year.ago.to_date], + [cookie.name, cookie.value, cookie.expires.to_date] end end |