From 519e7e5e1236dfb75a7d759e0a143bc9e0e47385 Mon Sep 17 00:00:00 2001 From: Jamis Buck Date: Wed, 8 Mar 2006 16:53:34 +0000 Subject: Fix problem with unloaded ARStore sessions being loaded when they are garbage collected, causing problems if there were AR objects in the session. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3817 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- .../test/activerecord/active_record_store_test.rb | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'actionpack/test') diff --git a/actionpack/test/activerecord/active_record_store_test.rb b/actionpack/test/activerecord/active_record_store_test.rb index 3ab6c40909..96c147c7d0 100644 --- a/actionpack/test/activerecord/active_record_store_test.rb +++ b/actionpack/test/activerecord/active_record_store_test.rb @@ -62,6 +62,10 @@ class ActiveRecordStoreTest < Test::Unit::TestCase CGI::Session::ActiveRecordStore::Session end + def session_id_column + "session_id" + end + def setup session_class.create_table! @@ -84,6 +88,20 @@ class ActiveRecordStoreTest < Test::Unit::TestCase assert_equal({ 'foo' => 'bar' }, @new_session.model.data) end + def test_save_unloaded_session + c = session_class.connection + bogus_class = c.quote(Base64.encode64("\004\010o:\vBlammo\000")) + c.insert("INSERT INTO #{session_class.table_name} ('#{session_id_column}', 'data') VALUES ('abcdefghijklmnop', #{bogus_class})") + + sess = session_class.find_by_session_id('abcdefghijklmnop') + assert_not_nil sess + assert !sess.loaded? + + # because the session is not loaded, the save should be a no-op. If it + # isn't, this'll try and unmarshall the bogus class, and should get an error. + assert_nothing_raised { sess.save } + end + def teardown session_class.drop_table! end @@ -110,6 +128,10 @@ class ColumnLimitTest < Test::Unit::TestCase end class DeprecatedActiveRecordStoreTest < ActiveRecordStoreTest + def session_id_column + "sessid" + end + def setup session_class.connection.execute 'create table old_sessions (id integer primary key, sessid text unique, data text)' session_class.table_name = 'old_sessions' -- cgit v1.2.3