Commit b8d8e4be authored by Mark Chao's avatar Mark Chao

Rename validate method to align with other checker class

BaseChecker uses validate instead of exec
parent 25fddbf4
......@@ -20,14 +20,11 @@ module Gitlab
@logger.append_message("Running checks for ref: #{@branch_name || @tag_name}")
end
def exec
def validate!
if creation? || deletion?
raise GitAccess::ForbiddenError, ERROR_MESSAGES[:create_delete_branch]
end
# TODO: https://gitlab.com/gitlab-org/gitlab/issues/205628
# Check operation will not result in more than one file in the repository
true
end
......
......@@ -97,9 +97,7 @@ module Gitlab
end
def check_single_change_access(change)
change_access = Checks::SnippetCheck.new(change, logger: logger)
change_access.exec
Checks::SnippetCheck.new(change, logger: logger).validate!
rescue Checks::TimedLogger::TimeoutError
raise TimeoutError, logger.full_message
end
......
......@@ -10,16 +10,16 @@ describe Gitlab::Checks::SnippetCheck do
subject { Gitlab::Checks::SnippetCheck.new(changes, logger: logger) }
describe '#exec' do
describe '#validate!' do
it 'does not raise any error' do
expect { subject.exec }.not_to raise_error
expect { subject.validate! }.not_to raise_error
end
context 'trying to delete the branch' do
let(:newrev) { '0000000000000000000000000000000000000000' }
it 'raises an error' do
expect { subject.exec }.to raise_error(Gitlab::GitAccess::ForbiddenError, 'You can not create or delete branches.')
expect { subject.validate! }.to raise_error(Gitlab::GitAccess::ForbiddenError, 'You can not create or delete branches.')
end
end
......@@ -28,14 +28,14 @@ describe Gitlab::Checks::SnippetCheck do
let(:ref) { 'refs/heads/feature' }
it 'raises an error' do
expect { subject.exec }.to raise_error(Gitlab::GitAccess::ForbiddenError, 'You can not create or delete branches.')
expect { subject.validate! }.to raise_error(Gitlab::GitAccess::ForbiddenError, 'You can not create or delete branches.')
end
context "when branch is 'master'" do
let(:ref) { 'refs/heads/master' }
it "allows the operation" do
expect { subject.exec }.not_to raise_error
expect { subject.validate! }.not_to raise_error
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