diff options
Diffstat (limited to 'actionpack/test/activerecord/active_record_store_test.rb')
-rw-r--r-- | actionpack/test/activerecord/active_record_store_test.rb | 22 |
1 files changed, 22 insertions, 0 deletions
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' |