database_cleaner
database_cleaner copied to clipboard
Remote database is wiped out
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.
A few thoughts:
- your remote DBs shouldn't be accessible through the public internet, e.g., from within your CI tool or the local machine
- you shouldn't have the remote DB's URLs (that include user/password) in your local env
- the user/password used for the application shouldn't have full permissions; create a user/role that can perform CRUD operations but can't truncate the DB; see the docs
- is Rails (assuming Rails is used) configured correctly to connect to your local DB when running tests? Is the
RAILS_ENV
var set correctly? - Which of the two DBs is wiped? Both? Only one? How are the DBs even configured?
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?
Closing this due to inactivity.