diff options
author | Sven Fuchs <svenfuchs@artweb-design.de> | 2008-07-16 03:41:11 +0200 |
---|---|---|
committer | Sven Fuchs <svenfuchs@artweb-design.de> | 2008-07-16 03:41:11 +0200 |
commit | 931f366ffcacc0444fcca2fb2e2b44644db9642f (patch) | |
tree | 4c056de1273d23e2b8494cfe452caaeb98ade820 /actionpack/test/active_record_unit.rb | |
parent | 8691e255402b27eae594530001227fc05416a00c (diff) | |
parent | fbef982e4b906b879240a35a1ecff447007da6b2 (diff) | |
download | rails-931f366ffcacc0444fcca2fb2e2b44644db9642f.tar.gz rails-931f366ffcacc0444fcca2fb2e2b44644db9642f.tar.bz2 rails-931f366ffcacc0444fcca2fb2e2b44644db9642f.zip |
merge forward to current rails/master
Diffstat (limited to 'actionpack/test/active_record_unit.rb')
-rw-r--r-- | actionpack/test/active_record_unit.rb | 58 |
1 files changed, 28 insertions, 30 deletions
diff --git a/actionpack/test/active_record_unit.rb b/actionpack/test/active_record_unit.rb index a7d526850e..a377ccad24 100644 --- a/actionpack/test/active_record_unit.rb +++ b/actionpack/test/active_record_unit.rb @@ -30,7 +30,6 @@ end $stderr.flush - # Define the rest of the connector class ActiveRecordTestConnector class << self @@ -48,46 +47,45 @@ class ActiveRecordTestConnector end private - - def setup_connection - if Object.const_defined?(:ActiveRecord) - defaults = { :database => ':memory:' } - begin - options = defaults.merge :adapter => 'sqlite3', :timeout => 500 - ActiveRecord::Base.establish_connection(options) - ActiveRecord::Base.configurations = { 'sqlite3_ar_integration' => options } - ActiveRecord::Base.connection - rescue Exception # errors from establishing a connection - $stderr.puts 'SQLite 3 unavailable; trying SQLite 2.' - options = defaults.merge :adapter => 'sqlite' - ActiveRecord::Base.establish_connection(options) - ActiveRecord::Base.configurations = { 'sqlite2_ar_integration' => options } - ActiveRecord::Base.connection + def setup_connection + if Object.const_defined?(:ActiveRecord) + defaults = { :database => ':memory:' } + begin + options = defaults.merge :adapter => 'sqlite3', :timeout => 500 + ActiveRecord::Base.establish_connection(options) + ActiveRecord::Base.configurations = { 'sqlite3_ar_integration' => options } + ActiveRecord::Base.connection + rescue Exception # errors from establishing a connection + $stderr.puts 'SQLite 3 unavailable; trying SQLite 2.' + options = defaults.merge :adapter => 'sqlite' + ActiveRecord::Base.establish_connection(options) + ActiveRecord::Base.configurations = { 'sqlite2_ar_integration' => options } + ActiveRecord::Base.connection + end + + Object.send(:const_set, :QUOTED_TYPE, ActiveRecord::Base.connection.quote_column_name('type')) unless Object.const_defined?(:QUOTED_TYPE) + else + raise "Can't setup connection since ActiveRecord isn't loaded." end - - Object.send(:const_set, :QUOTED_TYPE, ActiveRecord::Base.connection.quote_column_name('type')) unless Object.const_defined?(:QUOTED_TYPE) - else - raise "Can't setup connection since ActiveRecord isn't loaded." end - end - # Load actionpack sqlite tables - def load_schema - File.read(File.dirname(__FILE__) + "/fixtures/db_definitions/sqlite.sql").split(';').each do |sql| - ActiveRecord::Base.connection.execute(sql) unless sql.blank? + # Load actionpack sqlite tables + def load_schema + File.read(File.dirname(__FILE__) + "/fixtures/db_definitions/sqlite.sql").split(';').each do |sql| + ActiveRecord::Base.connection.execute(sql) unless sql.blank? + end end - end - def require_fixture_models - Dir.glob(File.dirname(__FILE__) + "/fixtures/*.rb").each {|f| require f} - end + def require_fixture_models + Dir.glob(File.dirname(__FILE__) + "/fixtures/*.rb").each {|f| require f} + end end end class ActiveRecordTestCase < ActiveSupport::TestCase # Set our fixture path if ActiveRecordTestConnector.able_to_connect - self.fixture_path = "#{File.dirname(__FILE__)}/fixtures/" + self.fixture_path = [FIXTURE_LOAD_PATH] self.use_transactional_fixtures = false end |