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