Sha256: 8232bd6e4713b6501cb5c51a76dfdccc155e8e0bf1ce9e2632fbf264b5d861bc

Contents?: true

Size: 863 Bytes

Versions: 3

Compression:

Stored size: 863 Bytes

Contents

require "active_record"
require "activerecord-safer_migrations"

ActiveRecord::SaferMigrations.load
ActiveRecord::Base.establish_connection

def silence_stream(stream)
  old_stream = stream.dup
  stream.reopen(IO::NULL)
  stream.sync = true
  yield
ensure
  stream.reopen(old_stream)
  old_stream.close
end

def nuke_migrations
  ActiveRecord::Base.connection_pool.with_connection do |conn|
    conn.execute("DROP TABLE IF EXISTS schema_migrations")
  end
end

module TimeoutTestHelpers
  def self.get(timeout_name)
    sql = <<-SQL
    SELECT
      setting AS #{timeout_name}
    FROM
      pg_settings
    WHERE
      name = '#{timeout_name}'
    SQL
    ActiveRecord::Base.connection.execute(sql).first[timeout_name.to_s].to_i
  end

  def self.set(timeout_name, timeout)
    ActiveRecord::Base.connection.execute("SET #{timeout_name} = #{timeout}")
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
activerecord-safer_migrations-2.0.0 spec/spec_helper.rb
activerecord-safer_migrations-1.0.0 spec/spec_helper.rb
activerecord-safer_migrations-0.1.0 spec/spec_helper.rb