diff options
author | Andrew Newdigate <andrew@gitlab.com> | 2019-06-25 09:15:35 +0000 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2019-06-25 09:15:35 +0000 |
commit | 84cb1bdaedbe192c5594d7586117191b865d8347 (patch) | |
tree | 0b181b9aee69d9230dc04de36b49f0ee49b6ceb1 /lib/after_commit_queue.rb | |
parent | e6a41c14e023627dba24ec321ddc0794fef41833 (diff) | |
download | gitlab-ce-84cb1bdaedbe192c5594d7586117191b865d8347.tar.gz |
Refactor inside_transaction? to Gitlab::Database
This is a small change to move AfterCommitQueue.inside_transaction?
to Gitlab::Database.inside_transaction? Since this change is required
by different changes which may not arrive in sequence, it's easier
to extract this change out on it's own.
Diffstat (limited to 'lib/after_commit_queue.rb')
-rw-r--r-- | lib/after_commit_queue.rb | 14 |
1 files changed, 1 insertions, 13 deletions
diff --git a/lib/after_commit_queue.rb b/lib/after_commit_queue.rb index 6fb7985f955..6a180fdf338 100644 --- a/lib/after_commit_queue.rb +++ b/lib/after_commit_queue.rb @@ -15,7 +15,7 @@ module AfterCommitQueue end def run_after_commit_or_now(&block) - if AfterCommitQueue.inside_transaction? + if Gitlab::Database.inside_transaction? if ActiveRecord::Base.connection.current_transaction.records.include?(self) run_after_commit(&block) else @@ -32,18 +32,6 @@ module AfterCommitQueue true end - def self.open_transactions_baseline - if ::Rails.env.test? - return DatabaseCleaner.connections.count { |conn| conn.strategy.is_a?(DatabaseCleaner::ActiveRecord::Transaction) } - end - - 0 - end - - def self.inside_transaction? - ActiveRecord::Base.connection.open_transactions > open_transactions_baseline - end - protected def _run_after_commit_queue |