Sha256: 19ef8bb58eb5feacca6769d4bd1688896ebec26fb8c68711ca05b72f578c4e19

Contents?: true

Size: 1.12 KB

Versions: 58

Compression:

Stored size: 1.12 KB

Contents

include ActiveRecord::Tasks

DatabaseTasks.database_configuration = YAML.load_file(File.join(Rails.root, 'config/database.yml'))
DatabaseTasks.db_dir = 'db'

def setup_db
  report = ClarkKent::Report.create(resource_type: 'Order')
  report.report_columns.create(column_name: 'user_name', column_order: 1)
  report.report_columns.create(column_name: 'id', column_order: 2)
  report.report_columns.create(column_name: 'amount', column_order: 3)
  report.report_columns.create(column_name: 'description', column_order: 4)
  d = Department.create(name: 'silly walks')
  u = User.create(name: 'Michael Hedges', email: 'taproot@gmail.com', department_id: d.id)
  Order.create(user_id: u.id, description: 'Guitar strings', amount: 1)
end

def clear_and_load_db
  real_stdout, $stdout = $stdout, StringIO.new

  DatabaseTasks.drop_current('test')
  DatabaseTasks.create_current('test')
  ActiveRecord::Migrator.migrations_paths = [ActiveRecord::Migrator.migrations_paths.first]
  DatabaseTasks.load_schema_current(ActiveRecord::Base.schema_format,File.join(Rails.root,'db/schema.rb'),'test')
ensure
  $stdout = real_stdout
end

clear_and_load_db
setup_db

Version data entries

58 entries across 58 versions & 1 rubygems

Version Path
clark_kent-0.11.3 test/support/db_utils.rb
clark_kent-0.11.2 test/support/db_utils.rb
clark_kent-0.11.1 test/support/db_utils.rb
clark_kent-0.11.0 test/support/db_utils.rb
clark_kent-0.10.4 test/support/db_utils.rb
clark_kent-0.10.2 test/support/db_utils.rb
clark_kent-0.10.1 test/support/db_utils.rb
clark_kent-0.10.0 test/support/db_utils.rb
clark_kent-0.9.9 test/support/db_utils.rb
clark_kent-0.9.8 test/support/db_utils.rb
clark_kent-0.9.7 test/support/db_utils.rb
clark_kent-0.9.6 test/support/db_utils.rb
clark_kent-0.9.5 test/support/db_utils.rb
clark_kent-0.9.4 test/support/db_utils.rb
clark_kent-0.9.2 test/support/db_utils.rb
clark_kent-0.9.1 test/support/db_utils.rb
clark_kent-0.9.0 test/support/db_utils.rb
clark_kent-0.8.11 test/support/db_utils.rb
clark_kent-0.8.10 test/support/db_utils.rb
clark_kent-0.8.9 test/support/db_utils.rb