Move RSpec config for streaming/search managers to be near classes (#27761)
This commit is contained in:
		@@ -11,10 +11,6 @@ if RUN_SYSTEM_SPECS
 | 
			
		||||
  ENV['STREAMING_API_BASE_URL'] = "http://localhost:#{STREAMING_PORT}"
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
if RUN_SEARCH_SPECS
 | 
			
		||||
  # Include any configuration or setups specific to search tests here
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
require File.expand_path('../config/environment', __dir__)
 | 
			
		||||
 | 
			
		||||
abort('The Rails environment is running in production mode!') if Rails.env.production?
 | 
			
		||||
@@ -35,8 +31,6 @@ Sidekiq.logger = nil
 | 
			
		||||
 | 
			
		||||
# System tests config
 | 
			
		||||
DatabaseCleaner.strategy = [:deletion]
 | 
			
		||||
streaming_server_manager = StreamingServerManager.new
 | 
			
		||||
search_data_manager = SearchDataManager.new
 | 
			
		||||
 | 
			
		||||
Devise::Test::ControllerHelpers.module_eval do
 | 
			
		||||
  alias_method :original_sign_in, :sign_in
 | 
			
		||||
@@ -100,26 +94,7 @@ RSpec.configure do |config|
 | 
			
		||||
    Capybara.current_driver = :rack_test
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  config.before :suite do
 | 
			
		||||
    if RUN_SYSTEM_SPECS
 | 
			
		||||
      Webpacker.compile
 | 
			
		||||
      streaming_server_manager.start(port: STREAMING_PORT)
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    if RUN_SEARCH_SPECS
 | 
			
		||||
      Chewy.strategy(:urgent)
 | 
			
		||||
      search_data_manager.prepare_test_data
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  config.after :suite do
 | 
			
		||||
    streaming_server_manager.stop
 | 
			
		||||
 | 
			
		||||
    search_data_manager.cleanup_test_data if RUN_SEARCH_SPECS
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  config.around :each, type: :system do |example|
 | 
			
		||||
    # driven_by :selenium, using: :chrome, screen_size: [1600, 1200]
 | 
			
		||||
    driven_by :selenium, using: :headless_chrome, screen_size: [1600, 1200]
 | 
			
		||||
 | 
			
		||||
    # The streaming server needs access to the database
 | 
			
		||||
@@ -136,12 +111,6 @@ RSpec.configure do |config|
 | 
			
		||||
    self.use_transactional_tests = true
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  config.around :each, type: :search do |example|
 | 
			
		||||
    search_data_manager.populate_indexes
 | 
			
		||||
    example.run
 | 
			
		||||
    search_data_manager.remove_indexes
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  config.before do |example|
 | 
			
		||||
    unless example.metadata[:paperclip_processing]
 | 
			
		||||
      allow_any_instance_of(Paperclip::Attachment).to receive(:post_process).and_return(true) # rubocop:disable RSpec/AnyInstance
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user