diff options
author | Jon Leighton <j@jonathanleighton.com> | 2011-01-08 18:33:33 +0000 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-01-11 13:45:06 -0800 |
commit | 80df74bf515124c9db85d4a670989ae5cc28c3ec (patch) | |
tree | f42a0ba9c629a4fc852b4de96d047be73cb2dffa /activerecord/test/connections/native_sqlite3 | |
parent | c6e10b0f600a56e962ff7d1614c50fca20630379 (diff) | |
download | rails-80df74bf515124c9db85d4a670989ae5cc28c3ec.tar.gz rails-80df74bf515124c9db85d4a670989ae5cc28c3ec.tar.bz2 rails-80df74bf515124c9db85d4a670989ae5cc28c3ec.zip |
Enable the sqlite3 in-memory test connection to work
Diffstat (limited to 'activerecord/test/connections/native_sqlite3')
-rw-r--r-- | activerecord/test/connections/native_sqlite3/in_memory_connection.rb | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/activerecord/test/connections/native_sqlite3/in_memory_connection.rb b/activerecord/test/connections/native_sqlite3/in_memory_connection.rb index 6aba9719bb..14e10900d1 100644 --- a/activerecord/test/connections/native_sqlite3/in_memory_connection.rb +++ b/activerecord/test/connections/native_sqlite3/in_memory_connection.rb @@ -1,4 +1,8 @@ -print "Using native SQLite3\n" +# This file connects to an in-memory SQLite3 database, which is a very fast way to run the tests. +# The downside is that disconnect from the database results in the database effectively being +# wiped. For this reason, pooled_connections_test.rb is disabled when using an in-memory database. + +print "Using native SQLite3 (in memory)\n" require_dependency 'models/course' require 'logger' ActiveRecord::Base.logger = Logger.new("debug.log") @@ -6,13 +10,10 @@ ActiveRecord::Base.logger = Logger.new("debug.log") class SqliteError < StandardError end -def make_connection(clazz, db_definitions_file) - clazz.establish_connection(:adapter => 'sqlite3', :database => ':memory:') - File.read(SCHEMA_ROOT + "/#{db_definitions_file}").split(';').each do |command| - clazz.connection.execute(command) unless command.strip.empty? - end +def make_connection(clazz) + ActiveRecord::Base.configurations = { clazz.name => { :adapter => 'sqlite3', :database => ':memory:' } } + clazz.establish_connection(clazz.name) end -make_connection(ActiveRecord::Base, 'sqlite.sql') -make_connection(Course, 'sqlite2.sql') -load(SCHEMA_ROOT + "/schema.rb") +make_connection(ActiveRecord::Base) +make_connection(Course) |