document safeguards

This commit is contained in:
Sven Fuchs 2018-03-24 17:05:29 +01:00 committed by Ernesto Tagwerker
parent bec3f64b78
commit 6843b8077e

View file

@ -502,6 +502,29 @@ Dir["#{Rails.root}/app/models/**/*.rb"].each do |model|
end
```
## Safeguards
DatabaseCleaner comes with safeguards against:
* Running in production (checking for `ENV`, `RACK_ENV`, and `RAILS_ENV`)
* Running against a remote database (checking for a `DATABASE_URL` that does not include `localhost`)
Both safeguards can be disabled separately as follows.
Using environment variables:
```
export DATABASE_CLEANER_ALLOW_PRODUCTION=true
export DATABASE_CLEANER_ALLOW_REMOTE_DATABASE_URL=true
```
In Ruby:
```ruby
DatabaseCleaner.allow_production = true
DatabaseCleaner.allow_remote_database_url = true
```
## Debugging
In rare cases DatabaseCleaner will encounter errors that it will log. By default it uses STDOUT set to the ERROR level but you can configure this to use whatever Logger you desire.