From 4e08a4892f01188255e803b87f641ef019bdb883 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Thu, 11 Jan 2024 05:54:42 -0500 Subject: [PATCH] Move streaming `around` config into manager class (#28684) --- spec/rails_helper.rb | 15 --------------- spec/support/streaming_server_manager.rb | 13 +++++++++++++ 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index aabb121fc3..aaf587f49b 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -107,21 +107,6 @@ RSpec.configure do |config| Capybara.current_driver = :rack_test 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| allow(Resolv::DNS).to receive(:open).and_raise('Real DNS queries are disabled, stub Resolv::DNS as needed') unless example.metadata[:type] == :system end diff --git a/spec/support/streaming_server_manager.rb b/spec/support/streaming_server_manager.rb index 2c535767e2..39657586f2 100644 --- a/spec/support/streaming_server_manager.rb +++ b/spec/support/streaming_server_manager.rb @@ -95,6 +95,19 @@ RSpec.configure do |config| 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 def streaming_server_manager