summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/models/project.rb2
-rw-r--r--spec/models/project_spec.rb22
2 files changed, 22 insertions, 2 deletions
diff --git a/app/models/project.rb b/app/models/project.rb
index f71bf65f417..0948e4625a8 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -1740,7 +1740,7 @@ class Project < ActiveRecord::Base
return false if ref.nil?
raise Repository::AmbiguousRefError if repository.ambiguous_ref?(ref)
- resolved_ref = repository.expand_ref(ref)
+ resolved_ref = repository.expand_ref(ref) || ref
ref_name = Gitlab::Git.ref_name(resolved_ref)
if Gitlab::Git.branch_ref?(resolved_ref)
diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb
index 75f1f779bb0..33bce0c0823 100644
--- a/spec/models/project_spec.rb
+++ b/spec/models/project_spec.rb
@@ -2625,7 +2625,27 @@ describe Project do
end
end
- context 'when ref name is a full branch ref' do
+ context 'when ref is a full ref' do
+ let(:ref) { 'refs/heads/master' }
+
+ context 'when ref is not protected' do
+ it 'returns false' do
+ is_expected.to be_falsey
+ end
+ end
+
+ context 'when ref is protected' do
+ before do
+ create(:protected_branch, name: 'master', project: project)
+ end
+
+ it 'returns true' do
+ is_expected.to be_truthy
+ end
+ end
+ end
+
+ context 'when ref name is a full tag ref' do
let(:ref) { 'refs/tags/something' }
before do