diff options
Diffstat (limited to 'spec/lib/gitlab/checks/branch_check_spec.rb')
-rw-r--r-- | spec/lib/gitlab/checks/branch_check_spec.rb | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/spec/lib/gitlab/checks/branch_check_spec.rb b/spec/lib/gitlab/checks/branch_check_spec.rb index 7f535e86d69..7ce267c535f 100644 --- a/spec/lib/gitlab/checks/branch_check_spec.rb +++ b/spec/lib/gitlab/checks/branch_check_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Gitlab::Checks::BranchCheck do +RSpec.describe Gitlab::Checks::BranchCheck, feature_category: :source_code_management do include_context 'change access checks context' describe '#validate!' do @@ -46,6 +46,23 @@ RSpec.describe Gitlab::Checks::BranchCheck do expect { subject.validate! }.not_to raise_error end end + + context 'when branch name is invalid' do + let(:ref) { 'refs/heads/-wrong' } + + it 'prohibits branches with an invalid name' do + expect { subject.validate! }.to raise_error(Gitlab::GitAccess::ForbiddenError, 'You cannot create a branch with an invalid name.') + end + + context 'deleting an invalid branch' do + let(:ref) { 'refs/heads/-wrong' } + let(:newrev) { '0000000000000000000000000000000000000000' } + + it "doesn't prohibit the deletion of an invalid branch name" do + expect { subject.validate! }.not_to raise_error + end + end + end end context 'protected branches check' do |