diff options
| author | Teddy Wing | 2017-12-13 16:16:44 +0100 |
|---|---|---|
| committer | Teddy Wing | 2017-12-13 16:16:44 +0100 |
| commit | 985d9a673a79f2b304119999dc76d418225332c7 (patch) | |
| tree | 668472879a44dcfab70d895707058eca251fb255 /spec/support/referential.rb | |
| parent | c21bcff5849190d87a2f2869a0f4714de118cb15 (diff) | |
| download | chouette-core-985d9a673a79f2b304119999dc76d418225332c7.tar.bz2 | |
spec/support/referential: Eliminate data errors in truncation tests
After the first `truncation: true` test ran, all tables would be
cleared. This caused errors as our tests rely on a referential like this
existing:
Referential.create(name: 'first')
It also caused problems with `LineReferential` as the `:chouette_line`
factory depends on an existing `LineReferential` associated to the
`first` Referential.
Add the `referentials` and `line_referentials` tables to the exclusion
list when truncating so these tables don't get cleared and the 'first'
records persist across test runs like before.
To prevent errors trying to unnecessarily switch to the 'first'
referential in `truncation: true` tests, disable that functionality by
adding a filter to exclude these tests from the normal transactional
`before(:each)` config block.
Refs #5024
Diffstat (limited to 'spec/support/referential.rb')
| -rw-r--r-- | spec/support/referential.rb | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/spec/support/referential.rb b/spec/support/referential.rb index c0ae35779..d00a9ba7f 100644 --- a/spec/support/referential.rb +++ b/spec/support/referential.rb @@ -72,14 +72,20 @@ RSpec.configure do |config| ) end - config.before(:each) do + config.before(:each, truncation: false) do DatabaseCleaner.strategy = :transaction # Switch into the default tenant first_referential.switch end config.before(:each, truncation: true) do - DatabaseCleaner.strategy = :truncation, { except: %w[spatial_ref_sys] } + DatabaseCleaner.strategy = :truncation, { + except: %w[ + spatial_ref_sys + referentials + line_referentials + ] + } end config.before(:each) do |
