Skip to content
This repository
Browse code

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...
commit 50619549eee6d3619c02bf9cb9eaadbbdb522913 1 parent fd901df
Jeremy Kemper authored
47  actionpack/test/controller/active_record_store_test.rb
@@ -15,15 +15,6 @@
15 15
 
16 16
 CGI::Session::ActiveRecordStore::Session.establish_connection(:adapter => 'sqlite3', :dbfile => ':memory:')
17 17
 
18  
-def setup_session_schema(connection, table_name = 'sessions', session_id_column_name = 'sessid', data_column_name = 'data')
19  
-  connection.execute <<-end_sql
20  
-    create table #{table_name} (
21  
-      id integer primary key,
22  
-      #{connection.quote_column_name(session_id_column_name)} text unique,
23  
-      #{connection.quote_column_name(data_column_name)} text
24  
-    )
25  
-  end_sql
26  
-end
27 18
 
28 19
 class ActiveRecordStoreTest < Test::Unit::TestCase
29 20
   def session_class
@@ -36,7 +27,7 @@ def setup
36 27
     ENV['REQUEST_METHOD'] = 'GET'
37 28
     CGI::Session::ActiveRecordStore.session_class = session_class
38 29
 
39  
-    @new_session = CGI::Session.new(CGI.new, :database_manager => CGI::Session::ActiveRecordStore, :new_session => true)
  30
+    @new_session = CGI::Session.new(CGI.new, 'database_manager' => CGI::Session::ActiveRecordStore, 'new_session' => true)
40 31
     @new_session['foo'] = 'bar'
41 32
   end
42 33
 
@@ -45,11 +36,21 @@ def teardown
45 36
   end
46 37
 
47 38
   def test_basics
  39
+    s = session_class.new(:session_id => '1234', :data => { 'foo' => 'bar' })
  40
+    assert_equal 'bar', s.data['foo']
  41
+    assert s.save!
  42
+    assert_equal 'bar', s.data['foo']
  43
+
  44
+    assert_not_nil t = session_class.find_by_session_id('1234')
  45
+    assert_not_nil t.data
  46
+    assert_equal 'bar', t.data['foo']
  47
+  end
  48
+
  49
+  def test_reload_same_session
48 50
     session_id = @new_session.session_id
49  
-    @new_session.close
50  
-    found = session_class.find_by_session_id(session_id)
51  
-    assert_not_nil found
52  
-    assert_equal 'bar', found.data['foo']
  51
+    @new_session.update
  52
+    reloaded = CGI::Session.new(CGI.new, 'session_id' => session_id, 'database_manager' => CGI::Session::ActiveRecordStore)
  53
+    assert_equal 'bar', reloaded['foo']
53 54
   end
54 55
 end
55 56
 
@@ -74,11 +75,21 @@ def teardown
74 75
   end
75 76
 
76 77
   def test_basics
  78
+    s = session_class.new(:session_id => '1234', :data => { 'foo' => 'bar' })
  79
+    assert_equal 'bar', s.data['foo']
  80
+    assert s.save!
  81
+    assert_equal 'bar', s.data['foo']
  82
+
  83
+    assert_not_nil t = session_class.find_by_session_id('1234')
  84
+    assert_not_nil t.data
  85
+    assert_equal 'bar', t.data['foo']
  86
+  end
  87
+
  88
+  def test_reload_same_session
77 89
     session_id = @new_session.session_id
78  
-    @new_session.close
79  
-    found = session_class.find_by_session_id(session_id)
80  
-    assert_not_nil found
81  
-    assert_equal 'bar', found.data['foo']
  90
+    @new_session.update
  91
+    reloaded = CGI::Session.new(CGI.new, 'session_id' => session_id, 'database_manager' => CGI::Session::ActiveRecordStore)
  92
+    assert_equal 'bar', reloaded['foo']
82 93
   end
83 94
 end
84 95
 

0 notes on commit 5061954

Please sign in to comment.
Something went wrong with that request. Please try again.