Skip to content

Fix order dependence in pending_build_spec

What does this MR do and why?

Since project is created with let_it_be, state set via assignment or could persist across examples in the spec.

To fix the problem, we do a combination of two things:

  1. let_it_be_with_refind to ensure state resets between tests on objects that are modified
  2. make changes on build.project instead of project in case they are different instances of the same underlying record

See #467641 (closed)

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After

How to set up and validate locally

To observe that this fixes #467641 (closed), run the following command

bin/rspec './spec/models/ci/pending_build_spec.rb[1:4:1:1,1:4:3:1]' --seed 27153 --format documentation

On master, the second example fails. On this branch, it succeeds.

In addition, you could run bin/rspec ./spec/models/ci/pending_build_spec.rb several times to check for regressions introduced by these changes.

Edited by Hordur Freyr Yngvason

Merge request reports