Sha256: fa24c24e76da519478c02406b7d7774871368bd78286dd57878b5661f7b40c95

Contents?: true

Size: 1.58 KB

Versions: 3

Compression:

Stored size: 1.58 KB

Contents

case ENV['DB']
when /mysql/i
  create_sql = 'CREATE DATABASE plugin_dev DEFAULT CHARACTER SET utf8;'
  if /:(.*)$/ =~ ENV['DB']
    create_sql.sub! ';', " DEFAULT COLLATE #{$1};"
  end

  `mysql -u root -e "DROP DATABASE IF EXISTS plugin_dev; #{create_sql}"`
  ActiveRecord::Base.establish_connection adapter: 'mysql2',
      database: 'plugin_dev', username: 'root', password: ''
when /pg/i
  pg_user = ENV['DB_USER'] || ENV['USER']
  `psql -U #{pg_user} -d postgres -c "DROP DATABASE IF EXISTS plugin_dev;"`
  `psql -U #{pg_user} -d postgres -c "CREATE DATABASE plugin_dev;"`
  ActiveRecord::Base.establish_connection adapter: 'postgresql',
      database: 'plugin_dev', username: pg_user, password: ''
else
  ActiveRecord::Base.establish_connection adapter: 'sqlite3',
                                          database: ':memory:'
end

class ActiveRecord::Base
  self.configurations = true
  if ActiveRecord::Base.respond_to? :mass_assignment_sanitizer=
    self.mass_assignment_sanitizer = :strict

    # Hacky equivalent to config.active_record.whitelist_attributes = true
    attr_accessible
  end
end

ActiveRecord::Migration.verbose = false
require File.expand_path('../../../test/migrations/001_create_attachments.rb',
                         __FILE__)
CreateAttachments.migrate :up
class Attachment < ActiveRecord::Base
end

class ActiveSupport::TestCase
  include ActiveRecord::TestFixtures

  self.fixture_path = File.expand_path '../../../test/fixtures', __FILE__
  self.use_transactional_fixtures = false
  self.use_instantiated_fixtures  = false
  self.pre_loaded_fixtures = false
  fixtures :all
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
binary_fixtures-0.1.2 test/helpers/db_setup.rb
binary_fixtures-0.1.1 test/helpers/db_setup.rb
binary_fixtures-0.1.0 test/helpers/db_setup.rb