Do not generate pipeline ref path if ref not present

This commit is contained in:
Grzegorz Bizon 2017-01-20 12:44:31 +01:00
parent 5a41d92b9d
commit 1f314195ea
2 changed files with 18 additions and 4 deletions

View file

@ -40,11 +40,13 @@ class PipelineEntity < Grape::Entity
end
expose :path do |pipeline|
if pipeline.ref
namespace_project_tree_path(
pipeline.project.namespace,
pipeline.project,
id: pipeline.ref)
end
end
expose :tag?, as: :tag
expose :branch?, as: :branch

View file

@ -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