Permalink
Browse files

r2808@asus: jeremy | 2005-07-04 19:08:48 -0700

 test at dbman and at CGI::Session level.  need to merge the test classes since they're the same tests for different backends..


git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1680 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent fd901df commit 50619549eee6d3619c02bf9cb9eaadbbdb522913 @jeremy jeremy committed Jul 4, 2005
Showing with 29 additions and 18 deletions.
  1. +29 −18 actionpack/test/controller/active_record_store_test.rb
@@ -15,15 +15,6 @@
CGI::Session::ActiveRecordStore::Session.establish_connection(:adapter => 'sqlite3', :dbfile => ':memory:')
-def setup_session_schema(connection, table_name = 'sessions', session_id_column_name = 'sessid', data_column_name = 'data')
- connection.execute <<-end_sql
- create table #{table_name} (
- id integer primary key,
- #{connection.quote_column_name(session_id_column_name)} text unique,
- #{connection.quote_column_name(data_column_name)} text
- )
- end_sql
-end
class ActiveRecordStoreTest < Test::Unit::TestCase
def session_class
@@ -36,7 +27,7 @@ def setup
ENV['REQUEST_METHOD'] = 'GET'
CGI::Session::ActiveRecordStore.session_class = session_class
- @new_session = CGI::Session.new(CGI.new, :database_manager => CGI::Session::ActiveRecordStore, :new_session => true)
+ @new_session = CGI::Session.new(CGI.new, 'database_manager' => CGI::Session::ActiveRecordStore, 'new_session' => true)
@new_session['foo'] = 'bar'
end
@@ -45,11 +36,21 @@ def teardown
end
def test_basics
+ s = session_class.new(:session_id => '1234', :data => { 'foo' => 'bar' })
+ assert_equal 'bar', s.data['foo']
+ assert s.save!
+ assert_equal 'bar', s.data['foo']
+
+ assert_not_nil t = session_class.find_by_session_id('1234')
+ assert_not_nil t.data
+ assert_equal 'bar', t.data['foo']
+ end
+
+ def test_reload_same_session
session_id = @new_session.session_id
- @new_session.close
- found = session_class.find_by_session_id(session_id)
- assert_not_nil found
- assert_equal 'bar', found.data['foo']
+ @new_session.update
+ reloaded = CGI::Session.new(CGI.new, 'session_id' => session_id, 'database_manager' => CGI::Session::ActiveRecordStore)
+ assert_equal 'bar', reloaded['foo']
end
end
@@ -74,11 +75,21 @@ def teardown
end
def test_basics
+ s = session_class.new(:session_id => '1234', :data => { 'foo' => 'bar' })
+ assert_equal 'bar', s.data['foo']
+ assert s.save!
+ assert_equal 'bar', s.data['foo']
+
+ assert_not_nil t = session_class.find_by_session_id('1234')
+ assert_not_nil t.data
+ assert_equal 'bar', t.data['foo']
+ end
+
+ def test_reload_same_session
session_id = @new_session.session_id
- @new_session.close
- found = session_class.find_by_session_id(session_id)
- assert_not_nil found
- assert_equal 'bar', found.data['foo']
+ @new_session.update
+ reloaded = CGI::Session.new(CGI.new, 'session_id' => session_id, 'database_manager' => CGI::Session::ActiveRecordStore)
+ assert_equal 'bar', reloaded['foo']
end
end

0 comments on commit 5061954

Please sign in to comment.