Do not generate pipeline ref path if ref not present
This commit is contained in:
parent
5a41d92b9d
commit
1f314195ea
2 changed files with 18 additions and 4 deletions
|
@ -40,10 +40,12 @@ class PipelineEntity < Grape::Entity
|
||||||
end
|
end
|
||||||
|
|
||||||
expose :path do |pipeline|
|
expose :path do |pipeline|
|
||||||
namespace_project_tree_path(
|
if pipeline.ref
|
||||||
pipeline.project.namespace,
|
namespace_project_tree_path(
|
||||||
pipeline.project,
|
pipeline.project.namespace,
|
||||||
id: pipeline.ref)
|
pipeline.project,
|
||||||
|
id: pipeline.ref)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
expose :tag?, as: :tag
|
expose :tag?, as: :tag
|
||||||
|
|
|
@ -134,5 +134,17 @@ describe PipelineEntity do
|
||||||
expect(subject).not_to have_key(:yaml_errors)
|
expect(subject).not_to have_key(:yaml_errors)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'when pipeline ref is empty' do
|
||||||
|
let(:pipeline) { create(:ci_empty_pipeline) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
allow(pipeline).to receive(:ref).and_return(nil)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'does not generate branch path' do
|
||||||
|
expect(subject[:ref][:path]).to be_nil
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue