Commit f19e84ee authored by Grzegorz Bizon's avatar Grzegorz Bizon Committed by Kamil Trzciński

Fix query analyzers base context / suppress keys

parent b087a567
......@@ -48,11 +48,15 @@ module Gitlab
end
def self.context_key
"#{self.class.name}_context"
@context_key ||= "analyzer_#{self.analyzer_key}_context".to_sym
end
def self.suppress_key
"#{self.class.name}_suppressed"
@suppress_key ||= "analyzer_#{self.analyzer_key}_suppressed".to_sym
end
def self.analyzer_key
@analyzer_key ||= self.name.demodulize.underscore.to_sym
end
end
end
......
......@@ -14,6 +14,22 @@ RSpec.describe Gitlab::Database::QueryAnalyzers::PreventCrossDatabaseModificatio
Gitlab::Database::QueryAnalyzer.instance.within { example.run }
end
describe 'context and suppress key names' do
describe '.context_key' do
it 'contains class name' do
expect(described_class.context_key)
.to eq 'analyzer_prevent_cross_database_modification_context'.to_sym
end
end
describe '.suppress_key' do
it 'contains class name' do
expect(described_class.suppress_key)
.to eq 'analyzer_prevent_cross_database_modification_suppressed'.to_sym
end
end
end
shared_examples 'successful examples' do |model:|
let(:model) { model }
......
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