Commit 837ab8c5 authored by Matija Čupić's avatar Matija Čupić

Make HasRef#git_ref public

parent 2edc0214
......@@ -7,15 +7,11 @@ module HasRef
!tag?
end
private
def git_ref
if branch?
Gitlab::Git::BRANCH_REF_PREFIX + ref.to_s
elsif tag?
Gitlab::Git::TAG_REF_PREFIX + ref.to_s
else
raise ArgumentError, 'Invalid pipeline type!'
end
end
end
......@@ -28,4 +28,32 @@ describe HasRef do
end
end
end
describe '#git_ref' do
subject { pipeline.git_ref }
context 'when tag is true' do
let(:pipeline) { create(:ci_pipeline, tag: true) }
it 'returns a tag ref' do
is_expected.to start_with(Gitlab::Git::TAG_REF_PREFIX)
end
end
context 'when tag is false' do
let(:pipeline) { create(:ci_pipeline, tag: false) }
it 'returns a branch ref' do
is_expected.to start_with(Gitlab::Git::BRANCH_REF_PREFIX)
end
end
context 'when tag is nil' do
let(:pipeline) { create(:ci_pipeline, tag: nil) }
it 'returns a branch ref' do
is_expected.to start_with(Gitlab::Git::BRANCH_REF_PREFIX)
end
end
end
end
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