Commit 0a1bdfce authored by Luke Duncalfe's avatar Luke Duncalfe

Remove redundant QueryLimiting.enable_whitelist?

The `.enable?` and `.enable_whitelist?` methods were originally
logically different cca61980 but converged in 04b64288.

This removes `.enable_whitelist?`.
parent 4e9466ae
......@@ -4,9 +4,8 @@ module Gitlab
module QueryLimiting
# Returns true if we should enable tracking of query counts.
#
# This is only enabled in production/staging if we're running on GitLab.com.
# This ensures we don't produce any errors that users can't do anything
# about themselves.
# This is only enabled in development and test to ensure we don't produce
# any errors that users of other environments can't do anything about themselves.
def self.enable?
Rails.env.development? || Rails.env.test?
end
......@@ -19,7 +18,7 @@ module Gitlab
# The issue URL is only meant to push developers into creating an issue
# instead of blindly whitelisting offending blocks of code.
def self.whitelist(issue_url)
return unless enable_whitelist?
return unless enable?
unless issue_url.start_with?('https://')
raise(
......@@ -30,9 +29,5 @@ module Gitlab
Transaction&.current&.whitelisted = true
end
def self.enable_whitelist?
Rails.env.development? || Rails.env.test?
end
end
end
......@@ -63,6 +63,20 @@ RSpec.describe Gitlab::QueryLimiting do
expect(transaction.count).to eq(before)
end
it 'whitelists when enabled' do
described_class.whitelist('https://example.com')
expect(transaction.whitelisted).to eq(true)
end
it 'does not whitelist when disabled' do
allow(described_class).to receive(:enable?).and_return(false)
described_class.whitelist('https://example.com')
expect(transaction.whitelisted).to eq(false)
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