2008-07-04 21:58:14 +04:00
|
|
|
$:.unshift(File.dirname(__FILE__) + '/../../../rails/activesupport/lib')
|
|
|
|
$:.unshift(File.dirname(__FILE__) + '/../../../rails/activerecord/lib')
|
2007-03-10 18:09:49 +03:00
|
|
|
$:.unshift(File.dirname(__FILE__) + '/../lib')
|
|
|
|
require 'test/unit'
|
2008-07-04 21:58:14 +04:00
|
|
|
begin
|
|
|
|
require 'active_support'
|
|
|
|
require 'active_record'
|
|
|
|
require 'active_record/fixtures'
|
|
|
|
rescue LoadError
|
|
|
|
require 'rubygems'
|
|
|
|
retry
|
|
|
|
end
|
|
|
|
require 'acts_as_versioned'
|
2007-03-10 18:09:49 +03:00
|
|
|
|
|
|
|
config = YAML::load(IO.read(File.dirname(__FILE__) + '/database.yml'))
|
|
|
|
ActiveRecord::Base.logger = Logger.new(File.dirname(__FILE__) + "/debug.log")
|
2008-07-04 21:58:14 +04:00
|
|
|
ActiveRecord::Base.configurations = {'test' => config[ENV['DB'] || 'sqlite3']}
|
|
|
|
ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations['test'])
|
2007-03-10 18:09:49 +03:00
|
|
|
|
|
|
|
load(File.dirname(__FILE__) + "/schema.rb")
|
|
|
|
|
|
|
|
# set up custom sequence on widget_versions for DBs that support sequences
|
|
|
|
if ENV['DB'] == 'postgresql'
|
|
|
|
ActiveRecord::Base.connection.execute "DROP SEQUENCE widgets_seq;" rescue nil
|
|
|
|
ActiveRecord::Base.connection.remove_column :widget_versions, :id
|
|
|
|
ActiveRecord::Base.connection.execute "CREATE SEQUENCE widgets_seq START 101;"
|
|
|
|
ActiveRecord::Base.connection.execute "ALTER TABLE widget_versions ADD COLUMN id INTEGER PRIMARY KEY DEFAULT nextval('widgets_seq');"
|
|
|
|
end
|
|
|
|
|
|
|
|
Test::Unit::TestCase.fixture_path = File.dirname(__FILE__) + "/fixtures/"
|
2008-07-04 21:58:14 +04:00
|
|
|
$:.unshift(Test::Unit::TestCase.fixture_path)
|
2007-03-10 18:09:49 +03:00
|
|
|
|
|
|
|
class Test::Unit::TestCase #:nodoc:
|
|
|
|
# Turn off transactional fixtures if you're working with MyISAM tables in MySQL
|
|
|
|
self.use_transactional_fixtures = true
|
|
|
|
|
|
|
|
# Instantiated fixtures are slow, but give you @david where you otherwise would need people(:david)
|
|
|
|
self.use_instantiated_fixtures = false
|
|
|
|
|
|
|
|
# Add more helper methods to be used by all tests here...
|
|
|
|
end
|