diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-12-28 15:10:50 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-12-28 15:10:50 +0300 |
commit | fdb0790ab5d98c4b0777d75f2630f33d050a2b5e (patch) | |
tree | 8a0d0ee42660b365bdf02317074be0200bed3587 /spec | |
parent | 38b2e0d403a2f879ca714ebde61d0611305fbd99 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r-- | spec/support/before_all_adapter.rb | 33 | ||||
-rw-r--r-- | spec/support/db_cleaner.rb | 2 | ||||
-rw-r--r-- | spec/support/helpers/database/multiple_databases_helpers.rb | 2 |
3 files changed, 2 insertions, 35 deletions
diff --git a/spec/support/before_all_adapter.rb b/spec/support/before_all_adapter.rb deleted file mode 100644 index 35846fcecb8..00000000000 --- 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 0a1d68a744c..b6539d6215b 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 bccd6979af1..9df0685e46a 100644 --- a/spec/support/helpers/database/multiple_databases_helpers.rb +++ b/spec/support/helpers/database/multiple_databases_helpers.rb @@ -85,7 +85,7 @@ module Database # 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. |