Commit 1d759895 authored by Shinya Maeda's avatar Shinya Maeda

Move conditional statement to PipelineSerializer#represent_status

parent a375d80e
...@@ -474,7 +474,6 @@ class Projects::MergeRequestsController < Projects::ApplicationController ...@@ -474,7 +474,6 @@ class Projects::MergeRequestsController < Projects::ApplicationController
end end
def pipeline_status def pipeline_status
render json: {} and return unless @merge_request.head_pipeline.present?
render json: PipelineSerializer render json: PipelineSerializer
.new(project: @project, user: @current_user) .new(project: @project, user: @current_user)
.represent_status(@merge_request.head_pipeline) .represent_status(@merge_request.head_pipeline)
......
...@@ -24,6 +24,7 @@ class PipelineSerializer < BaseSerializer ...@@ -24,6 +24,7 @@ class PipelineSerializer < BaseSerializer
end end
def represent_status(resource) def represent_status(resource)
return {} unless resource.present?
data = represent(resource, { only: [{ details: [:status] }] }) data = represent(resource, { only: [{ details: [:status] }] })
data.dig(:details, :status) || {} data.dig(:details, :status) || {}
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