* forgot to add test db helper
This commit is contained in:
parent
77b2cc0137
commit
ee8919481e
|
|
@ -0,0 +1,26 @@
|
|||
class SpecDb
|
||||
|
||||
TEST_DB_NAME="jam_web_test"
|
||||
|
||||
def self.recreate_database(db_config)
|
||||
recreate_database_jdbc(db_config)
|
||||
end
|
||||
|
||||
def self.recreate_database_jdbc(db_config)
|
||||
original = db_config["database"]
|
||||
db_config["database"] = "postgres"
|
||||
ActiveRecord::Base.establish_connection(db_config)
|
||||
ActiveRecord::Base.connection.execute("DROP DATABASE IF EXISTS #{TEST_DB_NAME}")
|
||||
ActiveRecord::Base.connection.execute("CREATE DATABASE #{TEST_DB_NAME}")
|
||||
JamDb::Migrator.new.migrate(:dbname => TEST_DB_NAME)
|
||||
db_config["database"] = original
|
||||
end
|
||||
|
||||
def self.recreate_database_pg
|
||||
|
||||
conn = PG::Connection.open("dbname=postgres")
|
||||
conn.exec("DROP DATABASE IF EXISTS #{TEST_DB_NAME}")
|
||||
conn.exec("CREATE DATABASE #{TEST_DB_NAME}")
|
||||
JamDb::Migrator.new.migrate(:dbname => TEST_DB_NAME)
|
||||
end
|
||||
end
|
||||
Loading…
Reference in New Issue