Commit 4467ae0c authored by Adam Hegyi's avatar Adam Hegyi

Merge branch 'move-query-analyzers-to-before' into 'master'

Register `QueryAnalayzers` in `config.before` to fix `let_it_be`

See merge request gitlab-org/gitlab!76567
parents 60010802 f45171bc
......@@ -67,8 +67,6 @@ module Gitlab
end
end
private
# Enable query analyzers
def begin!
analyzers = all_analyzers.select do |analyzer|
......@@ -97,6 +95,8 @@ module Gitlab
Thread.current[:query_analyzer_enabled_analyzers] = nil
end
private
def enabled_analyzers
Thread.current[:query_analyzer_enabled_analyzers]
end
......
......@@ -4,11 +4,15 @@
# can be disabled selectively
RSpec.configure do |config|
config.around do |example|
config.before do |example|
if example.metadata.fetch(:query_analyzers, true)
::Gitlab::Database::QueryAnalyzer.instance.within { example.run }
else
example.run
::Gitlab::Database::QueryAnalyzer.instance.begin!
end
end
config.after do |example|
if example.metadata.fetch(:query_analyzers, true)
::Gitlab::Database::QueryAnalyzer.instance.end!
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment