summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatija Čupić <matteeyah@gmail.com>2018-11-30 12:18:53 +0100
committerMatija Čupić <matteeyah@gmail.com>2018-12-08 19:28:57 +0100
commit93d3c61eca258369bda0c28c5519cb14e4ff1457 (patch)
treef7292046fb4bc963440ba6f44b19bab5d856b79f
parent0f00c7818bf09e800c4ac6652077fffe7976ed6b (diff)
downloadgitlab-ce-93d3c61eca258369bda0c28c5519cb14e4ff1457.tar.gz
Add specs when full ref is passed to protected_for
-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