PageRenderTime 47ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/vendor/plugins/acts_as_versioned/test/abstract_unit.rb

https://github.com/dramatis/dramatis-redmine
Ruby | 40 lines | 27 code | 9 blank | 4 comment | 4 complexity | f1b18f818e2982962840cbbc94609297 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1
  1. $:.unshift(File.dirname(__FILE__) + '/../lib')
  2. require 'test/unit'
  3. require File.expand_path(File.join(File.dirname(__FILE__), '../../../../config/environment.rb'))
  4. require 'active_record/fixtures'
  5. config = YAML::load(IO.read(File.dirname(__FILE__) + '/database.yml'))
  6. ActiveRecord::Base.logger = Logger.new(File.dirname(__FILE__) + "/debug.log")
  7. ActiveRecord::Base.establish_connection(config[ENV['DB'] || 'sqlite'])
  8. load(File.dirname(__FILE__) + "/schema.rb")
  9. # set up custom sequence on widget_versions for DBs that support sequences
  10. if ENV['DB'] == 'postgresql'
  11. ActiveRecord::Base.connection.execute "DROP SEQUENCE widgets_seq;" rescue nil
  12. ActiveRecord::Base.connection.remove_column :widget_versions, :id
  13. ActiveRecord::Base.connection.execute "CREATE SEQUENCE widgets_seq START 101;"
  14. ActiveRecord::Base.connection.execute "ALTER TABLE widget_versions ADD COLUMN id INTEGER PRIMARY KEY DEFAULT nextval('widgets_seq');"
  15. end
  16. Test::Unit::TestCase.fixture_path = File.dirname(__FILE__) + "/fixtures/"
  17. $LOAD_PATH.unshift(Test::Unit::TestCase.fixture_path)
  18. class Test::Unit::TestCase #:nodoc:
  19. def create_fixtures(*table_names)
  20. if block_given?
  21. Fixtures.create_fixtures(Test::Unit::TestCase.fixture_path, table_names) { yield }
  22. else
  23. Fixtures.create_fixtures(Test::Unit::TestCase.fixture_path, table_names)
  24. end
  25. end
  26. # Turn off transactional fixtures if you're working with MyISAM tables in MySQL
  27. self.use_transactional_fixtures = true
  28. # Instantiated fixtures are slow, but give you @david where you otherwise would need people(:david)
  29. self.use_instantiated_fixtures = false
  30. # Add more helper methods to be used by all tests here...
  31. end