Permalink
Browse files

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
  • Loading branch information...
jeremy committed Jul 5, 2005
1 parent 56c3d72 commit 1e6603e6e71e6378e1a9f88871344a60757ccd78
@@ -251,24 +251,28 @@ def initialize(session, option = nil)
# 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
@@ -40,6 +40,13 @@ def test_reload_same_session
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

0 comments on commit 1e6603e

Please sign in to comment.