Commit 0f00c781 authored by Matija Čupić's avatar Matija Čupić

Remove resolving conditional from protected_for

parent 08942de9
......@@ -1740,13 +1740,8 @@ class Project < ActiveRecord::Base
return false if ref.nil?
raise Repository::AmbiguousRefError if repository.ambiguous_ref?(ref)
if Gitlab::Git.branch_ref?(ref) || Gitlab::Git.tag_ref?(ref)
resolved_ref = ref
ref_name = Gitlab::Git.ref_name(ref)
else
resolved_ref = repository.expand_ref(ref)
ref_name = ref
end
ref_name = Gitlab::Git.ref_name(resolved_ref)
if Gitlab::Git.branch_ref?(resolved_ref)
ProtectedBranch.protected?(self, ref_name)
......
......@@ -2624,6 +2624,28 @@ describe Project do
is_expected.to be_truthy
end
end
context 'when ref name is a full branch ref' do
let(:ref) { 'refs/tags/something' }
before do
project.repository.add_branch(project.creator, ref, 'master')
end
it 'returns false' do
is_expected.to be_falsey
end
context 'when ref is a protected branch' do
before do
create(:protected_branch, name: 'refs/tags/something', project: project)
end
it 'returns true' do
is_expected.to be_truthy
end
end
end
end
describe '#update_project_statistics' 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