• Yorick Peterse's avatar
    Link merge requests for all non review app deploys · 67c20fc4
    Yorick Peterse authored
    This changes how we link merge requests to deployments so that:
    
    1. We link merge requests for any deployment that is not in the
       "created" state.
    2. We do not link merge requests to review app deployments.
    
    We want to link deployments regardless of their status so that we can
    also show failed and running deploys in the merge request widget (and
    perhaps in other places). We don't want to link review app deployments
    since this is not useful, and may lead to deployments to different
    review app environments showing up on a merge request page.
    
    This builds on the refactoring of the deployment model introduced in
    merge request https://gitlab.com/gitlab-org/gitlab/merge_requests/20474,
    and moves the linking of merge requests to Deployments::FinishedWorker.
    This worker is scheduled every time a deployment transitions to a
    finished state.
    
    As part of these changes we also change Deployment#link_merge_requests
    so that it ignores any already linked merge requests. This way if a
    deployment changes its status multiple times, we don't error with
    duplicate key errors.
    
    This fixes https://gitlab.com/gitlab-org/gitlab/issues/38092.
    67c20fc4
deployment_spec.rb 15 KB