Sha256: 1cdbfb4234dba574780a90a911ed4965471b541e0287f1929b2a4247ad326c75

Contents?: true

Size: 1008 Bytes

Versions: 14

Compression:

Stored size: 1008 Bytes

Contents

print "Using native PostgreSQL\n"

adapter_name = 'postgresql'
config = YAML.load_file(File.join(File.dirname(__FILE__), '/../../connection.yml'))[adapter_name]

#require 'logger'
#ActiveRecord::Base.logger = Logger.new("debug.log")

ActiveRecord::Base.silence do
  ActiveRecord::Base.configurations = {
  'rails_sql_views_unittest' => {
    :adapter  => adapter_name,
    :username => config['username'],
    :password => config['password'],
    :host     => config['host'],
    :database => config['database'],
    :encoding => config['encoding'],
    :schema_file => config['schema_file'],
  }
  }

  ActiveRecord::Base.establish_connection config['database']

  puts "Resetting database"
  conn = ActiveRecord::Base.connection
  #conn.recreate_database(conn.current_database)
  conn.reconnect!
  lines = open(File.join(File.dirname(__FILE__), ActiveRecord::Base.configurations[config['database']][:schema_file])).readlines
  lines.join.split(';').each { |line| conn.execute(line) }
  conn.reconnect!
end

Version data entries

14 entries across 14 versions & 5 rubygems

Version Path
rails_sql_views4-0.0.3 test/connection/native_postgresql/connection.rb
rails_sql_views4-0.0.2 test/connection/native_postgresql/connection.rb
rails_sql_views4-0.0.1 test/connection/native_postgresql/connection.rb
robdimarco_rails_sql_views-0.9.0 test/connection/native_postgresql/connection.rb
qubole_rails_sql_views-0.10.1 test/connection/native_postgresql/connection.rb
qubole_rails_sql_views-0.10.0 test/connection/native_postgresql/connection.rb
molo-0.7.6 vendor/rails_sql_views/test/connection/native_postgresql/connection.rb
molo-0.7.5 vendor/rails_sql_views/test/connection/native_postgresql/connection.rb
molo-0.7.4 vendor/rails_sql_views/test/connection/native_postgresql/connection.rb
molo-0.7.3 vendor/rails_sql_views/test/connection/native_postgresql/connection.rb
molo-0.7.2 vendor/rails_sql_views/test/connection/native_postgresql/connection.rb
molo-0.7.1 vendor/rails_sql_views/test/connection/native_postgresql/connection.rb
molo-0.7.0 vendor/rails_sql_views/test/connection/native_postgresql/connection.rb
rails_sql_views-0.8.0 test/connection/native_postgresql/connection.rb