Move streaming `around` config into manager class (#28684)

This commit is contained in:
Matt Jankowski 2024-01-11 05:54:42 -05:00 committed by GitHub
parent 87097a227c
commit 4e08a4892f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 15 deletions

View File

@ -107,21 +107,6 @@ RSpec.configure do |config|
Capybara.current_driver = :rack_test Capybara.current_driver = :rack_test
end end
config.around :each, type: :system do |example|
# The streaming server needs access to the database
# but with use_transactional_tests every transaction
# is rolled-back, so the streaming server never sees the data
# So we disable this feature for system tests, and use DatabaseCleaner to clean
# the database tables between each test
self.use_transactional_tests = false
DatabaseCleaner.cleaning do
example.run
end
self.use_transactional_tests = true
end
config.before do |example| config.before do |example|
allow(Resolv::DNS).to receive(:open).and_raise('Real DNS queries are disabled, stub Resolv::DNS as needed') unless example.metadata[:type] == :system allow(Resolv::DNS).to receive(:open).and_raise('Real DNS queries are disabled, stub Resolv::DNS as needed') unless example.metadata[:type] == :system
end end

View File

@ -95,6 +95,19 @@ RSpec.configure do |config|
end end
end end
config.around :each, type: :system do |example|
# Streaming server needs DB access but `use_transactional_tests` rolls back
# every transaction. Disable this feature for streaming tests, and use
# DatabaseCleaner to clean the database tables between each test.
self.use_transactional_tests = false
DatabaseCleaner.cleaning do
example.run
end
self.use_transactional_tests = true
end
private private
def streaming_server_manager def streaming_server_manager