Commit 1f314195 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Do not generate pipeline ref path if ref not present

parent 5a41d92b
...@@ -40,10 +40,12 @@ class PipelineEntity < Grape::Entity ...@@ -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 ...@@ -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
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