Commit 5df655e0 authored by Peter Leitzen's avatar Peter Leitzen

Merge branch 'fj-add-flag-snippet_count_check' into 'master'

Add flag snippet_count_check to GitAccessSnippet

See merge request gitlab-org/gitlab!27702
parents 5e98bf42 b21a23c7
...@@ -98,7 +98,10 @@ module Gitlab ...@@ -98,7 +98,10 @@ module Gitlab
def check_single_change_access(change) def check_single_change_access(change)
Checks::SnippetCheck.new(change, logger: logger).validate! Checks::SnippetCheck.new(change, logger: logger).validate!
if Feature.enabled?(:snippet_count_check)
Checks::PushFileCountCheck.new(change, repository: repository, limit: Snippet::MAX_FILE_COUNT, logger: logger).validate! Checks::PushFileCountCheck.new(change, repository: repository, limit: Snippet::MAX_FILE_COUNT, logger: logger).validate!
end
rescue Checks::TimedLogger::TimeoutError rescue Checks::TimedLogger::TimeoutError
raise TimeoutError, logger.full_message raise TimeoutError, logger.full_message
end end
......
...@@ -209,6 +209,16 @@ describe Gitlab::GitAccessSnippet do ...@@ -209,6 +209,16 @@ describe Gitlab::GitAccessSnippet do
expect { push_access_check }.to raise_forbidden('foo') expect { push_access_check }.to raise_forbidden('foo')
end end
context 'when feature flag :snippet_count_check is disabled' do
it 'does not check push file count' do
stub_feature_flags(snippet_count_check: false)
expect(Gitlab::Checks::PushFileCountCheck).not_to receive(:new)
expect { push_access_check }.not_to raise_error
end
end
end end
private private
......
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