Skip to content

Fix flaky spec: Don't destroy project created in let_it_be block

Rutger Wessels requested to merge rw-fix-flaky-spec-api-internal-base into master

What does this MR do and why?

While working on another MR, I ran into a failing spec, which turns out to be flaky:

  1. we create a project using let_it_be(:project)
  2. one of the specs destroys project (project.destroy!)
  3. Another spec calls let_it_be(:project) so the project will be recreated

Specs that use project between 2 and 3 can break due to the fact that the project has been removed from the database

On master branch, I was able to reproduce this using

rspec --order random --seed 45791 ./spec/requests/api/internal/base_spec.rb

Fix:

  • Create a project for the specs that need a destroyed project
  • Remove the duplicate let_it_be(:project) call
Edited by Rutger Wessels

Merge request reports

Loading