diff --git a/.rubocop_todo/layout/line_end_string_concatenation_indentation.yml b/.rubocop_todo/layout/line_end_string_concatenation_indentation.yml index 7bc8d09558528926f93f4c78a279a4b07a7f4c1e..8c05d745fbb7a39f7d3aecf052b332e7a8a14466 100644 --- a/.rubocop_todo/layout/line_end_string_concatenation_indentation.yml +++ b/.rubocop_todo/layout/line_end_string_concatenation_indentation.yml @@ -293,7 +293,6 @@ Layout/LineEndStringConcatenationIndentation: - 'spec/services/snippets/create_service_spec.rb' - 'spec/services/users/email_verification/validate_token_service_spec.rb' - 'spec/services/work_items/parent_links/create_service_spec.rb' - - 'spec/support/before_all_adapter.rb' - 'spec/support/helpers/database/multiple_databases_helpers.rb' - 'spec/support/helpers/redis_without_keys.rb' - 'spec/support/matchers/have_gitlab_http_status.rb' diff --git a/.rubocop_todo/style/inline_disable_annotation.yml b/.rubocop_todo/style/inline_disable_annotation.yml index db42f855d1a343b6b1fde6787096f8343dc0c8ae..9dbb54954f844d9f1296914acca9b034a17e5d56 100644 --- a/.rubocop_todo/style/inline_disable_annotation.yml +++ b/.rubocop_todo/style/inline_disable_annotation.yml @@ -3153,7 +3153,6 @@ Style/InlineDisableAnnotation: - 'spec/sidekiq/cron/job_gem_dependency_spec.rb' - 'spec/sidekiq_cluster/sidekiq_cluster_spec.rb' - 'spec/spec_helper.rb' - - 'spec/support/before_all_adapter.rb' - 'spec/support/capybara.rb' - 'spec/support/database/click_house/hooks.rb' - 'spec/support/db_cleaner.rb' diff --git a/.rubocop_todo/style/redundant_self.yml b/.rubocop_todo/style/redundant_self.yml index 701ce4db7df7a32c4f019570eb63a482330da06a..8c23290babeb85b73205dec4f750aaa2dbd1a75a 100644 --- a/.rubocop_todo/style/redundant_self.yml +++ b/.rubocop_todo/style/redundant_self.yml @@ -384,4 +384,3 @@ Style/RedundantSelf: - 'spec/lib/gitlab/background_task_spec.rb' - 'spec/lib/gitlab/database/load_balancing_spec.rb' - 'spec/models/integration_spec.rb' - - 'spec/support/before_all_adapter.rb' diff --git a/spec/support/before_all_adapter.rb b/spec/support/before_all_adapter.rb deleted file mode 100644 index 35846fcecb8b49e182c455b32f03c05dec89c02f..0000000000000000000000000000000000000000 --- a/spec/support/before_all_adapter.rb +++ /dev/null @@ -1,33 +0,0 @@ -# frozen_string_literal: true - -module TestProfBeforeAllAdapter - module MultipleDatabaseAdapter - def self.all_connection_classes - @all_connection_classes ||= [ActiveRecord::Base] + ActiveRecord::Base.descendants.select(&:connection_class?) # rubocop: disable Database/MultipleDatabases - end - - def self.begin_transaction - self.all_connection_classes.each do |connection_class| - connection_class.connection.begin_transaction(joinable: false) - end - end - - def self.rollback_transaction - self.all_connection_classes.each do |connection_class| - if connection_class.connection.open_transactions.zero? - warn "!!! before_all transaction has been already rollbacked and " \ - "could work incorrectly" - next - end - - connection_class.connection.rollback_transaction - end - end - end - - def self.default_adapter - MultipleDatabaseAdapter - end -end - -TestProf::BeforeAll.adapter = ::TestProfBeforeAllAdapter.default_adapter diff --git a/spec/support/db_cleaner.rb b/spec/support/db_cleaner.rb index 0a1d68a744cc49973190477fadeef4e4c048fa3f..b6539d6215b6acf7dc8e90110610336e8c6ba6f6 100644 --- a/spec/support/db_cleaner.rb +++ b/spec/support/db_cleaner.rb @@ -2,7 +2,7 @@ module DbCleaner def all_connection_classes - ::TestProfBeforeAllAdapter::MultipleDatabaseAdapter.all_connection_classes + ::TestProf::BeforeAll::Adapters::ActiveRecord.all_connections.map(&:connection_class).uniq end def delete_from_all_tables!(except: []) diff --git a/spec/support/helpers/database/multiple_databases_helpers.rb b/spec/support/helpers/database/multiple_databases_helpers.rb index bccd6979af1409fb4edf15747a7bf351ce0c1a5e..9df0685e46adfe0b3b2cb0c639beb68c6c91f064 100644 --- a/spec/support/helpers/database/multiple_databases_helpers.rb +++ b/spec/support/helpers/database/multiple_databases_helpers.rb @@ -85,7 +85,7 @@ def ensure_schema_and_empty_tables # The usage of this method switches temporarily used `connection_handler` # allowing full manipulation of ActiveRecord::Base connections without # having side effects like: - # - misaligned transactions since this is managed by `BeforeAllAdapter` + # - misaligned transactions since this is managed by `TestProf::BeforeAll::Adapters::ActiveRecord` # - removal of primary connections # # The execution within a block ensures safe cleanup of all allocated resources.