summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Trzciński <ayufan@ayufan.eu>2017-01-21 12:21:47 +0000
committerKamil Trzciński <ayufan@ayufan.eu>2017-01-21 12:21:47 +0000
commit6fe2adda838d7072ff9e960cc80ba7023b53bc34 (patch)
treeec3f42ca3f08d4d0b8d789054a2cd0afa3f7061b
parentbb6f931bc39dc504661767b96436985dfb47d84e (diff)
parent36afc97486e53a8ba70773eaf06b16cce07bd08b (diff)
downloadgitlab-ce-6fe2adda838d7072ff9e960cc80ba7023b53bc34.tar.gz
Merge branch 'fix/pipeline-ref-path-serialization' into 'master'
Do not generate pipeline ref path if ref not present Closes #26861 See merge request !8658
-rw-r--r--app/serializers/pipeline_entity.rb10
-rw-r--r--changelogs/unreleased/fix-pipeline-ref-path-serialization.yml4
-rw-r--r--spec/serializers/pipeline_entity_spec.rb12
3 files changed, 22 insertions, 4 deletions
diff --git a/app/serializers/pipeline_entity.rb b/app/serializers/pipeline_entity.rb
index d04a4990cb0..61f0f11d7d2 100644
--- a/app/serializers/pipeline_entity.rb
+++ b/app/serializers/pipeline_entity.rb
@@ -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
diff --git a/changelogs/unreleased/fix-pipeline-ref-path-serialization.yml b/changelogs/unreleased/fix-pipeline-ref-path-serialization.yml
new file mode 100644
index 00000000000..f60ab01a6f1
--- /dev/null
+++ b/changelogs/unreleased/fix-pipeline-ref-path-serialization.yml
@@ -0,0 +1,4 @@
+---
+title: Do not generate pipeline branch/tag path if not present
+merge_request: 8658
+author:
diff --git a/spec/serializers/pipeline_entity_spec.rb b/spec/serializers/pipeline_entity_spec.rb
index b19464c7117..ccb72973f9c 100644
--- a/spec/serializers/pipeline_entity_spec.rb
+++ b/spec/serializers/pipeline_entity_spec.rb
@@ -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