Move conditional statement to PipelineSerializer#represent_status

This commit is contained in:
Shinya Maeda 2017-03-23 17:18:11 +09:00
parent a375d80eb0
commit 1d75989551
2 changed files with 1 additions and 1 deletions

View File

@ -474,7 +474,6 @@ class Projects::MergeRequestsController < Projects::ApplicationController
end
def pipeline_status
render json: {} and return unless @merge_request.head_pipeline.present?
render json: PipelineSerializer
.new(project: @project, user: @current_user)
.represent_status(@merge_request.head_pipeline)

View File

@ -24,6 +24,7 @@ class PipelineSerializer < BaseSerializer
end
def represent_status(resource)
return {} unless resource.present?
data = represent(resource, { only: [{ details: [:status] }] })
data.dig(:details, :status) || {}
end