mirror of
https://github.com/DatabaseCleaner/database_cleaner
synced 2023-03-27 23:22:03 -04:00
Allow local tld on safeguard check on DATABASE_URL
This commit is contained in:
parent
fa07bc064c
commit
eece968212
3 changed files with 10 additions and 2 deletions
|
@ -507,7 +507,7 @@ end
|
|||
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`)
|
||||
* Running against a remote database (checking for a `DATABASE_URL` that does not include `localhost`, `.local` or `127.0.0.1`)
|
||||
|
||||
Both safeguards can be disabled separately as follows.
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ module DatabaseCleaner
|
|||
end
|
||||
|
||||
class RemoteDatabaseUrl
|
||||
LOCAL = %w(localhost 127.0.0.1 sqlite3:)
|
||||
LOCAL = %w(localhost .local 127.0.0.1 sqlite3:)
|
||||
|
||||
def run
|
||||
raise Error::RemoteDatabaseUrl if !skip? && given?
|
||||
|
|
|
@ -28,6 +28,14 @@ module DatabaseCleaner
|
|||
end
|
||||
end
|
||||
|
||||
describe 'to a local tld url' do
|
||||
let(:database_url) { 'postgres://postgres.local' }
|
||||
|
||||
it 'does not raise' do
|
||||
expect { cleaner.start }.to_not raise_error
|
||||
end
|
||||
end
|
||||
|
||||
describe 'to a 127.0.0.1 url' do
|
||||
let(:database_url) { 'postgres://127.0.0.1' }
|
||||
|
||||
|
|
Loading…
Reference in a new issue