mirror of
https://github.com/DatabaseCleaner/database_cleaner
synced 2023-03-27 23:22:03 -04:00
delay running safeguards until right before cleaning begins. this allows for time to configure safeguards.
This commit is contained in:
parent
44bbfe5386
commit
f8b7e052e6
3 changed files with 6 additions and 3 deletions
|
@ -1,5 +1,4 @@
|
|||
require 'database_cleaner/null_strategy'
|
||||
require 'database_cleaner/safeguard'
|
||||
require 'database_cleaner/strategy'
|
||||
require 'forwardable'
|
||||
|
||||
|
@ -28,7 +27,6 @@ module DatabaseCleaner
|
|||
def initialize(orm, db: nil)
|
||||
@orm = orm
|
||||
self.db = db
|
||||
Safeguard.new.run
|
||||
end
|
||||
|
||||
attr_reader :orm
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
require 'database_cleaner/cleaner'
|
||||
require 'database_cleaner/safeguard'
|
||||
|
||||
module DatabaseCleaner
|
||||
class Cleaners < Hash
|
||||
|
@ -18,20 +19,24 @@ module DatabaseCleaner
|
|||
end
|
||||
|
||||
def start
|
||||
Safeguard.new.run
|
||||
values.each { |cleaner| cleaner.start }
|
||||
end
|
||||
|
||||
def clean
|
||||
Safeguard.new.run
|
||||
values.each { |cleaner| cleaner.clean }
|
||||
end
|
||||
|
||||
def cleaning(&inner_block)
|
||||
Safeguard.new.run
|
||||
values.inject(inner_block) do |curr_block, cleaner|
|
||||
proc { cleaner.cleaning(&curr_block) }
|
||||
end.call
|
||||
end
|
||||
|
||||
def clean_with(*args)
|
||||
Safeguard.new.run
|
||||
values.each { |cleaner| cleaner.clean_with(*args) }
|
||||
end
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
module DatabaseCleaner
|
||||
RSpec.describe Safeguard do
|
||||
let(:cleaner) { Cleaner.new(:null) }
|
||||
let(:cleaner) { Cleaners.new }
|
||||
|
||||
describe 'DATABASE_URL is set' do
|
||||
before { stub_const('ENV', 'DATABASE_URL' => database_url) }
|
||||
|
|
Loading…
Reference in a new issue