starting sql bypass test, fixing create_table and drop_table!

This commit is contained in:
Aaron Patterson
2010-07-21 16:36:22 -07:00
parent bdbe390a98
commit ba0d2a9ce3
2 changed files with 26 additions and 4 deletions

View File

@@ -217,17 +217,17 @@ module ActiveRecord
end
def create_table!
@@connection.execute <<-end_sql
connection.execute <<-end_sql
CREATE TABLE #{table_name} (
id INTEGER PRIMARY KEY,
#{@@connection.quote_column_name(session_id_column)} TEXT UNIQUE,
#{@@connection.quote_column_name(data_column)} TEXT
#{connection.quote_column_name(session_id_column)} TEXT UNIQUE,
#{connection.quote_column_name(data_column)} TEXT
)
end_sql
end
def drop_table!
@@connection.execute "DROP TABLE #{table_name}"
connection.execute "DROP TABLE #{table_name}"
end
end

View File

@@ -0,0 +1,22 @@
require 'cases/helper'
require 'action_dispatch'
require 'active_record/session_store'
module ActiveRecord
class SessionStore
class SqlBypassTest < ActiveRecord::TestCase
def setup
super
Session.drop_table! if Session.table_exists?
end
def test_create_table
assert !Session.table_exists?
SqlBypass.create_table!
assert Session.table_exists?
SqlBypass.drop_table!
assert !Session.table_exists?
end
end
end
end