Sha256: 2c62118d3b3d9516e1e5a5b9abb7228d005f62d605685c832a655bec9742e16b

Contents?: true

Size: 536 Bytes

Versions: 74

Compression:

Stored size: 536 Bytes

Contents

module CleanDbHelpers
  def current_db
    ActiveRecord::Base.connection_config[:database]
  end

  def save_clean_db(clean_file)
    `pg_dump -O -Fc #{current_db} > #{clean_file}`
  end

  def restore_clean_db(clean_file, remove_file = true)
    self.use_transactional_fixtures = false
    `pg_restore -j 2 -O -x -c -d #{current_db} #{clean_file}`
    `rm -f #{clean_file}` if remove_file
    ActiveRecord::Base.clear_all_connections!
    ActiveRecord::Base.reset_shared_connection
    self.use_transactional_fixtures = true
  end
end

Version data entries

74 entries across 74 versions & 1 rubygems

Version Path
marty-1.2.9 spec/support/clean_db_helpers.rb
marty-1.2.8 spec/support/clean_db_helpers.rb
marty-1.2.7 spec/support/clean_db_helpers.rb
marty-1.2.6 spec/support/clean_db_helpers.rb
marty-1.2.5 spec/support/clean_db_helpers.rb
marty-1.2.4 spec/support/clean_db_helpers.rb
marty-1.2.3 spec/support/clean_db_helpers.rb
marty-1.2.2 spec/support/clean_db_helpers.rb
marty-1.2.1 spec/support/clean_db_helpers.rb
marty-1.2.0 spec/support/clean_db_helpers.rb
marty-1.1.9 spec/support/clean_db_helpers.rb
marty-1.1.8 spec/support/clean_db_helpers.rb
marty-1.1.7 spec/support/clean_db_helpers.rb
marty-1.1.6 spec/support/clean_db_helpers.rb
marty-1.1.5 spec/support/clean_db_helpers.rb
marty-1.1.4 spec/support/clean_db_helpers.rb
marty-1.1.3 spec/support/clean_db_helpers.rb
marty-1.1.2 spec/support/clean_db_helpers.rb
marty-1.1.1 spec/support/clean_db_helpers.rb
marty-1.0.54 spec/support/clean_db_helpers.rb