Skip to content
This repository
Browse code

starting sql bypass test, fixing create_table and drop_table!

  • Loading branch information...
commit ba0d2a9ce374df69647a8280459d59000ce43188 1 parent bdbe390
Aaron Patterson authored July 21, 2010
8  activerecord/lib/active_record/session_store.rb
@@ -217,17 +217,17 @@ def unmarshal(data)
217 217
         end
218 218
 
219 219
         def create_table!
220  
-          @@connection.execute <<-end_sql
  220
+          connection.execute <<-end_sql
221 221
             CREATE TABLE #{table_name} (
222 222
               id INTEGER PRIMARY KEY,
223  
-              #{@@connection.quote_column_name(session_id_column)} TEXT UNIQUE,
224  
-              #{@@connection.quote_column_name(data_column)} TEXT
  223
+              #{connection.quote_column_name(session_id_column)} TEXT UNIQUE,
  224
+              #{connection.quote_column_name(data_column)} TEXT
225 225
             )
226 226
           end_sql
227 227
         end
228 228
 
229 229
         def drop_table!
230  
-          @@connection.execute "DROP TABLE #{table_name}"
  230
+          connection.execute "DROP TABLE #{table_name}"
231 231
         end
232 232
       end
233 233
 
22  activerecord/test/cases/session_store/sql_bypass.rb
... ...
@@ -0,0 +1,22 @@
  1
+require 'cases/helper'
  2
+require 'action_dispatch'
  3
+require 'active_record/session_store'
  4
+
  5
+module ActiveRecord
  6
+  class SessionStore
  7
+    class SqlBypassTest < ActiveRecord::TestCase
  8
+      def setup
  9
+        super
  10
+        Session.drop_table! if Session.table_exists?
  11
+      end
  12
+
  13
+      def test_create_table
  14
+        assert !Session.table_exists?
  15
+        SqlBypass.create_table!
  16
+        assert Session.table_exists?
  17
+        SqlBypass.drop_table!
  18
+        assert !Session.table_exists?
  19
+      end
  20
+    end
  21
+  end
  22
+end

0 notes on commit ba0d2a9

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