Commit 20ec88c7 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Merge branch 'bvl-fix-push-rule-without-branch' into 'master'

Fix when pushing without a branch name

Closes #3393

See merge request !2879
parents fd326fc3 efc89795
......@@ -177,7 +177,7 @@ module Gitlab
def branch_name_allowed_by_push_rule?(push_rule)
return true unless push_rule
return true if @branch_name.empty?
return true if @branch_name.blank?
push_rule.branch_name_allowed?(@branch_name)
end
......
......@@ -249,6 +249,14 @@ describe Gitlab::Checks::ChangeAccess do
expect { subject }.to raise_error(Gitlab::GitAccess::UnauthorizedError, "Branch name does not follow the pattern '^(w*)$'")
end
context 'when the ref is not a branch ref' do
let(:ref) { 'a/ref/thats/not/abranch' }
it 'allows the creation' do
expect { subject }.not_to raise_error
end
end
context 'when no commits are present' do
before do
allow(project.repository).to receive(:new_commits) { [] }
......
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