Skip to content

Make previousStageJobsOrNeeds return union

Laura Montemayor requested to merge fix-build-need-id-job-type into master

What does this MR do and why?

Updates the return type for previousStageJobsOrNeeds to be a BuildNeedType instead of a JobType. This caused an incident because the previous_stage_jobs_or_needs method was returning Ci::BuildNeed objects instead of the jobs that matches the defined needs. Ci::BuildNeed does not have a type method, so when JobType tried to calculate the id using the below method, a NoMethodError was thrown.

       def id                                                                                                                                          
         return unless object.id.present?                                                                                                              
                                                                                                                                                       
         model_name = object.type || ::CommitStatus.name                                                                                               
         id = object.id                                                                                                                                
         Gitlab::GlobalId.build(model_name: model_name, id: id)                                                                                        
       end 

This MR also updates the spec with an id to prove that this is working now.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

#348287 (closed)

Edited by Laura Montemayor

Merge request reports

Loading