Commit 93d3c61e authored by Matija Čupić's avatar Matija Čupić

Add specs when full ref is passed to protected_for

parent 0f00c781
......@@ -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)
......
......@@ -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
......
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