diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2005-07-05 14:50:07 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2005-07-05 14:50:07 +0000 |
commit | 1e6603e6e71e6378e1a9f88871344a60757ccd78 (patch) | |
tree | 8f3e8c22eab2dea9b2e1da39c48f1405e802ed16 | |
parent | 56c3d72aa75dd286e35a220f53297e043e799ab2 (diff) | |
download | rails-1e6603e6e71e6378e1a9f88871344a60757ccd78.tar.gz rails-1e6603e6e71e6378e1a9f88871344a60757ccd78.tar.bz2 rails-1e6603e6e71e6378e1a9f88871344a60757ccd78.zip |
r2850@asus: jeremy | 2005-07-05 13:08:32 -0700
Don't be strict about the order in which AR store methods are called. Allow e.g. session close followed by session close.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1710 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r-- | actionpack/lib/action_controller/session/active_record_store.rb | 16 | ||||
-rw-r--r-- | actionpack/test/controller/active_record_store_test.rb | 7 |
2 files changed, 17 insertions, 6 deletions
diff --git a/actionpack/lib/action_controller/session/active_record_store.rb b/actionpack/lib/action_controller/session/active_record_store.rb index 4700f2419a..60fd295fe8 100644 --- a/actionpack/lib/action_controller/session/active_record_store.rb +++ b/actionpack/lib/action_controller/session/active_record_store.rb @@ -251,24 +251,28 @@ class CGI # Restore session state. The session model handles unmarshaling. def restore - @session.data + @session.data if @session end # Save session store. def update - @session.save! + @session.save! if @session end # Save and close the session store. def close - update - @session = nil + if @session + update + @session = nil + end end # Delete and close the session store. def delete - @session.destroy rescue nil - @session = nil + if @session + @session.destroy rescue nil + @session = nil + end end end diff --git a/actionpack/test/controller/active_record_store_test.rb b/actionpack/test/controller/active_record_store_test.rb index cc7f23bed5..b50d08447b 100644 --- a/actionpack/test/controller/active_record_store_test.rb +++ b/actionpack/test/controller/active_record_store_test.rb @@ -40,6 +40,13 @@ module CommonActiveRecordStoreTests reloaded = CGI::Session.new(CGI.new, 'session_id' => @new_session.session_id, 'database_manager' => CGI::Session::ActiveRecordStore) assert_equal 'bar', reloaded['foo'] end + + def test_tolerates_close_close + assert_nothing_raised do + @new_session.close + @new_session.close + end + end end class ActiveRecordStoreTest < Test::Unit::TestCase |