Skip to content
代码片段 群组 项目
提交 8408df8e 编辑于 作者: charlie ablett's avatar charlie ablett
浏览文件

Merge branch 'ld-remove-redundant-enable-method' into 'master'

Remove redundant `QueryLimiting.enable_whitelist?` method

See merge request gitlab-org/gitlab!55715
No related branches found
No related tags found
无相关合并请求
...@@ -4,9 +4,8 @@ module Gitlab ...@@ -4,9 +4,8 @@ module Gitlab
module QueryLimiting module QueryLimiting
# Returns true if we should enable tracking of query counts. # 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 is only enabled in development and test to ensure we don't produce
# This ensures we don't produce any errors that users can't do anything # any errors that users of other environments can't do anything about themselves.
# about themselves.
def self.enable? def self.enable?
Rails.env.development? || Rails.env.test? Rails.env.development? || Rails.env.test?
end end
...@@ -19,7 +18,7 @@ def self.enable? ...@@ -19,7 +18,7 @@ def self.enable?
# The issue URL is only meant to push developers into creating an issue # The issue URL is only meant to push developers into creating an issue
# instead of blindly whitelisting offending blocks of code. # instead of blindly whitelisting offending blocks of code.
def self.whitelist(issue_url) def self.whitelist(issue_url)
return unless enable_whitelist? return unless enable?
unless issue_url.start_with?('https://') unless issue_url.start_with?('https://')
raise( raise(
...@@ -30,9 +29,5 @@ def self.whitelist(issue_url) ...@@ -30,9 +29,5 @@ def self.whitelist(issue_url)
Transaction&.current&.whitelisted = true Transaction&.current&.whitelisted = true
end end
def self.enable_whitelist?
Rails.env.development? || Rails.env.test?
end
end end
end end
...@@ -63,6 +63,20 @@ ...@@ -63,6 +63,20 @@
expect(transaction.count).to eq(before) expect(transaction.count).to eq(before)
end 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 end
end end
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册