Sha256: 4f3559cb18b1548f084f557bd281e74ed40245a597f27239de0424e115534948

Contents?: true

Size: 530 Bytes

Versions: 30

Compression:

Stored size: 530 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_tests = 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_tests = true
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
marty-2.4.0 spec/support/clean_db_helpers.rb
marty-2.3.14 spec/support/clean_db_helpers.rb
marty-2.3.13 spec/support/clean_db_helpers.rb
marty-2.3.12 spec/support/clean_db_helpers.rb
marty-2.3.11 spec/support/clean_db_helpers.rb
marty-2.3.10 spec/support/clean_db_helpers.rb
marty-2.3.9 spec/support/clean_db_helpers.rb
marty-2.3.8 spec/support/clean_db_helpers.rb
marty-2.3.7 spec/support/clean_db_helpers.rb
marty-2.3.5 spec/support/clean_db_helpers.rb
marty-2.3.4 spec/support/clean_db_helpers.rb
marty-2.1.5 spec/support/clean_db_helpers.rb
marty-2.3.2 spec/support/clean_db_helpers.rb
marty-2.3.1 spec/support/clean_db_helpers.rb
marty-2.3.0 spec/support/clean_db_helpers.rb
marty-2.1.4 spec/support/clean_db_helpers.rb
marty-2.1.3 spec/support/clean_db_helpers.rb
marty-2.1.2 spec/support/clean_db_helpers.rb
marty-2.1.1 spec/support/clean_db_helpers.rb
marty-2.1.0 spec/support/clean_db_helpers.rb