fix acceptance tests to actually use default strategy, now that :truncation is no longer a safe default for all adapters.

This commit is contained in:
Micah Geisel 2020-05-30 09:10:41 -07:00
parent d087c1d2a6
commit 781a4a096d
5 changed files with 15 additions and 10 deletions

View file

@ -47,16 +47,22 @@ if orm && strategy
case orm_sym
when :redis
DatabaseCleaner[orm_sym, db: ENV['REDIS_URL_ONE']].strategy = strategy.to_sym
DatabaseCleaner[orm_sym, db: ENV['REDIS_URL_TWO']].strategy = strategy.to_sym
cleaner = DatabaseCleaner[orm_sym, db: ENV['REDIS_URL_ONE']]
cleaner.strategy = strategy.to_sym unless strategy == "default"
cleaner = DatabaseCleaner[orm_sym, db: ENV['REDIS_URL_TWO']]
cleaner.strategy = strategy.to_sym unless strategy == "default"
when :active_record
DatabaseCleaner[:active_record, db: ActiveRecordWidgetUsingDatabaseOne].strategy = strategy.to_sym
DatabaseCleaner[:active_record, db: ActiveRecordWidgetUsingDatabaseTwo].strategy = strategy.to_sym
cleaner = DatabaseCleaner[:active_record, db: ActiveRecordWidgetUsingDatabaseOne]
cleaner.strategy = strategy.to_sym unless strategy == "default"
cleaner = DatabaseCleaner[:active_record, db: ActiveRecordWidgetUsingDatabaseTwo]
cleaner.strategy = strategy.to_sym unless strategy == "default"
end
elsif another_orm
DatabaseCleaner[ orm.gsub(/(.)([A-Z]+)/,'\1_\2').downcase.to_sym].strategy = strategy.to_sym
DatabaseCleaner[another_orm.gsub(/(.)([A-Z]+)/,'\1_\2').downcase.to_sym].strategy = strategy.to_sym
cleaner = DatabaseCleaner[ orm.gsub(/(.)([A-Z]+)/,'\1_\2').downcase.to_sym]
cleaner.strategy = strategy.to_sym unless strategy == "default"
cleaner = DatabaseCleaner[another_orm.gsub(/(.)([A-Z]+)/,'\1_\2').downcase.to_sym]
cleaner.strategy = strategy.to_sym unless strategy == "default"
else
DatabaseCleaner.strategy = strategy.to_sym unless strategy == "default"
end

View file

@ -15,4 +15,4 @@ Feature: database cleaning
| ActiveRecord | transaction |
| ActiveRecord | truncation |
| ActiveRecord | deletion |
| Redis | truncation |
| Redis | deletion |

View file

@ -15,5 +15,5 @@ Feature: multiple database cleaning
| ActiveRecord | truncation |
| ActiveRecord | deletion |
| ActiveRecord | transaction |
| Redis | truncation |
| Redis | deletion |

View file

@ -5,7 +5,6 @@ Feature: database cleaning using multiple ORMs
Scenario Outline: ruby app with adapter gems
Given I am using <ORM1> and <ORM2> from their adapter gems
When I run my scenarios that rely on clean databases using multiple orms
Then I should see all green

View file

@ -22,7 +22,7 @@ class FeatureRunner
attr_accessor :output
def strategy
@strategy || 'truncation'
@strategy ||= "default"
end
def go(feature)