DEV: Fix not flushing Redis properly for system test. (#29188)
In ed6c9d1545
, we started flushing
Redis's database at the end of each test. However, we had something like
this:
```
config.after(:each, type: :system) { teardown system test stuff }
config.after(:each) { # flush redis }
```
When stuff was defined in this order, flushing redis was called before
the teardown of system test. Instead we have to switch the order around
which is what this commit does.
This commit is contained in:
parent
bb5a58a686
commit
c949d95951
|
@ -678,6 +678,33 @@ RSpec.configure do |config|
|
|||
BlockRequestsMiddleware.current_example_location = example.location
|
||||
end
|
||||
|
||||
config.after :each do |example|
|
||||
if example.exception && RspecErrorTracker.exceptions.present?
|
||||
lines = (RSpec.current_example.metadata[:extra_failure_lines] ||= +"")
|
||||
|
||||
lines << "~~~~~~~ SERVER EXCEPTIONS ~~~~~~~"
|
||||
|
||||
RspecErrorTracker.exceptions.each_with_index do |(path, ex), index|
|
||||
lines << "\n"
|
||||
lines << "Error encountered while proccessing #{path}"
|
||||
lines << " #{ex.class}: #{ex.message}"
|
||||
ex.backtrace.each_with_index do |line, backtrace_index|
|
||||
if ENV["RSPEC_EXCLUDE_GEMS_IN_BACKTRACE"]
|
||||
next if line.match?(%r{/gems/})
|
||||
end
|
||||
lines << " #{line}\n"
|
||||
end
|
||||
end
|
||||
|
||||
lines << "~~~~~~~ END SERVER EXCEPTIONS ~~~~~~~"
|
||||
lines << "\n"
|
||||
end
|
||||
|
||||
unfreeze_time
|
||||
ActionMailer::Base.deliveries.clear
|
||||
Discourse.redis.flushdb
|
||||
end
|
||||
|
||||
config.after(:each, type: :system) do |example|
|
||||
lines = RSpec.current_example.metadata[:extra_failure_lines]
|
||||
|
||||
|
@ -738,33 +765,6 @@ RSpec.configure do |config|
|
|||
MessageBus.backend_instance.reset! # Clears all existing backlog from memory backend
|
||||
end
|
||||
|
||||
config.after :each do |example|
|
||||
if example.exception && RspecErrorTracker.exceptions.present?
|
||||
lines = (RSpec.current_example.metadata[:extra_failure_lines] ||= +"")
|
||||
|
||||
lines << "~~~~~~~ SERVER EXCEPTIONS ~~~~~~~"
|
||||
|
||||
RspecErrorTracker.exceptions.each_with_index do |(path, ex), index|
|
||||
lines << "\n"
|
||||
lines << "Error encountered while proccessing #{path}"
|
||||
lines << " #{ex.class}: #{ex.message}"
|
||||
ex.backtrace.each_with_index do |line, backtrace_index|
|
||||
if ENV["RSPEC_EXCLUDE_GEMS_IN_BACKTRACE"]
|
||||
next if line.match?(%r{/gems/})
|
||||
end
|
||||
lines << " #{line}\n"
|
||||
end
|
||||
end
|
||||
|
||||
lines << "~~~~~~~ END SERVER EXCEPTIONS ~~~~~~~"
|
||||
lines << "\n"
|
||||
end
|
||||
|
||||
unfreeze_time
|
||||
ActionMailer::Base.deliveries.clear
|
||||
Discourse.redis.flushdb
|
||||
end
|
||||
|
||||
config.before(:each, type: :multisite) do
|
||||
Rails.configuration.multisite = true # rubocop:disable Discourse/NoDirectMultisiteManipulation
|
||||
|
||||
|
|
Loading…
Reference in New Issue