Skip to content

Commit

Permalink
r2808@asus: jeremy | 2005-07-04 19:08:48 -0700
Browse files Browse the repository at this point in the history
 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
jeremy committed Jul 4, 2005
1 parent fd901df commit 5061954
Showing 1 changed file with 29 additions and 18 deletions.
47 changes: 29 additions & 18 deletions actionpack/test/controller/active_record_store_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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

Expand All @@ -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

Expand Down

0 comments on commit 5061954

Please sign in to comment.