DatabaseCleaner / database_cleaner

Strategies for cleaning databases in Ruby. Can be used to ensure a clean state for testing.
https://www.rubydoc.info/github/DatabaseCleaner/database_cleaner
MIT License
2.93k stars 484 forks source link

Remote database is wiped out #687

Closed jonatasdaniel closed 1 year ago

jonatasdaniel commented 3 years ago

I have two databases in my app (ActiveRecord (Postgres) and MongoID (MongoDB)) with this config:

config.before(:suite) do
  DatabaseCleaner[:active_record].clean_with(:truncation)
  DatabaseCleaner[:mongoid].clean_with(:deletion)
end

config.before(:each) do
  DatabaseCleaner[:active_record].strategy = :transaction
  DatabaseCleaner[:mongoid].strategy = :deletion
end

config.before(:each, js: true) do
  DatabaseCleaner[:active_record].strategy = :truncation
end

config.before(:each) do
  DatabaseCleaner.start
end

but running my specs with DATABASE_URL set on my env, I got the Safeguard::Error::RemoteDatabaseUrl error but my remote database keeps getting wiped out.

swiknaba commented 2 years ago

A few thoughts:

Most likely, this is not an issue of the database cleaner gem. How should this gem know which database you intend to truncate? "Remote" doesn't necessarily mean that is the wrong DB; you could run your test DB on a remote server, nothing wrong with that from the point of view of this gem?

etagwerker commented 1 year ago

Closing this due to inactivity.