Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/database_cleaner/cleaner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def strategy=(args)
raise ArgumentError, "You must provide a strategy object, or a symbol for a known strategy along with initialization params."
end

set_strategy_db @strategy, db
set_strategy_db self.strategy, db
end

def strategy
Expand Down
8 changes: 8 additions & 0 deletions spec/database_cleaner/cleaner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,14 @@ module DatabaseCleaner
cleaner.strategy = :truncation, { param: "one" }
end

it "accepts nil as the null strategy for a non-default database" do
cleaner.db = :test_db
cleaner.strategy = nil

expect(cleaner.strategy).to be_a(DatabaseCleaner::NullStrategy)
expect(cleaner.cleaning { :result }).to eq :result
end

it "should accept strategy objects" do
strategy = double
cleaner.strategy = strategy
Expand Down
10 changes: 10 additions & 0 deletions spec/database_cleaner/cleaners_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,16 @@
end
end

it "sets the null strategy across default and non-default databases" do
cleaners[:active_record]
cleaners[:active_record, db: :second_db]

cleaners.strategy = nil

expect(cleaners.strategy.values).to all(be_a(DatabaseCleaner::NullStrategy))
expect(cleaners.cleaning { :result }).to eq :result
end

context "top level api methods" do
context "single orm single db" do
let!(:cleaner) { cleaners[:active_record] }
Expand Down