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
|
||||
|
||||
expose :path do |pipeline|
|
||||
namespace_project_tree_path(
|
||||
pipeline.project.namespace,
|
||||
pipeline.project,
|
||||
id: pipeline.ref)
|
||||
if pipeline.ref
|
||||
namespace_project_tree_path(
|
||||
pipeline.project.namespace,
|
||||
pipeline.project,
|
||||
id: pipeline.ref)
|
||||
end
|
||||
end
|
||||
|
||||
expose :tag?, as: :tag
|
||||
|
|
|
@ -134,5 +134,17 @@ describe PipelineEntity do
|
|||
expect(subject).not_to have_key(:yaml_errors)
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue