class DatabaseCleaner::Safeguard::RemoteDatabaseUrl

Constants

LOCAL

Public Instance Methods

run() click to toggle source
# File lib/database_cleaner/safeguard.rb, line 44
def run
  raise Error::RemoteDatabaseUrl if !skip? && given?
end

Private Instance Methods

given?() click to toggle source
# File lib/database_cleaner/safeguard.rb, line 50
def given?
  remote?(ENV['DATABASE_URL'])
end
remote?(url) click to toggle source
# File lib/database_cleaner/safeguard.rb, line 54
def remote?(url)
  return false unless url

  parsed = URI.parse(url)
  return false if parsed.scheme == 'sqlite3:'

  host = parsed.host
  return false unless host
  return false if LOCAL.include?(host)
  return false if host.end_with? '.local'
  true
end
skip?() click to toggle source
# File lib/database_cleaner/safeguard.rb, line 67
def skip?
  ENV['DATABASE_CLEANER_ALLOW_REMOTE_DATABASE_URL'] ||
    DatabaseCleaner.allow_remote_database_url ||
    DatabaseCleaner.url_allowlist
end