Fix pipeline reference existence check and add specs
This commit is contained in:
parent
49d7c3b346
commit
5f412e3a87
|
@ -269,7 +269,7 @@ module Ci
|
||||||
end
|
end
|
||||||
|
|
||||||
def ref_exists?
|
def ref_exists?
|
||||||
project.repository.ref_exists?(self.ref)
|
project.repository.ref_exists?(git_ref)
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -678,11 +678,11 @@ module Ci
|
||||||
|
|
||||||
def push_details
|
def push_details
|
||||||
strong_memoize(:push_details) do
|
strong_memoize(:push_details) do
|
||||||
Gitlab::Git::Push.new(project, before_sha, sha, push_ref)
|
Gitlab::Git::Push.new(project, before_sha, sha, git_ref)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def push_ref
|
def git_ref
|
||||||
if branch?
|
if branch?
|
||||||
Gitlab::Git::BRANCH_REF_PREFIX + ref.to_s
|
Gitlab::Git::BRANCH_REF_PREFIX + ref.to_s
|
||||||
elsif tag?
|
elsif tag?
|
||||||
|
|
|
@ -779,6 +779,29 @@ describe Ci::Pipeline, :mailer do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'ref_exists?' do
|
||||||
|
using RSpec::Parameterized::TableSyntax
|
||||||
|
|
||||||
|
let(:project) { create(:project, :repository) }
|
||||||
|
|
||||||
|
where(:tag, :ref, :result) do
|
||||||
|
false | 'master' | true
|
||||||
|
false | 'non-existent-branch' | false
|
||||||
|
true | 'v1.1.0' | true
|
||||||
|
true | 'non-existent-tag' | false
|
||||||
|
end
|
||||||
|
|
||||||
|
with_them do
|
||||||
|
let(:pipeline) do
|
||||||
|
create(:ci_empty_pipeline, project: project, tag: tag, ref: ref)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "correctly detects ref" do
|
||||||
|
expect(pipeline.ref_exists?).to be result
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context 'with non-empty project' do
|
context 'with non-empty project' do
|
||||||
let(:project) { create(:project, :repository) }
|
let(:project) { create(:project, :repository) }
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue