Skip to content

Clear protected branch cache upon creation in test

Stan Hu requested to merge sh-cache-clear-protected-branch into master

What does this MR do and why?

The introduction of the protected branch caching via the hash_based_cache_for_protected_branches feature flag could cause tests to fail since the protected branch cache might have the wrong values.

Normally the cache is refreshed since protected branches are created with ProtectedBranches::CreateService, but in tests FactoryBot creates them without the service. To ensure the cache is in a good state in tests, mimic this cache clearing after the creation of a protected branch in the factory.

Relates to #371944 (closed)

How to set up and validate locally

Previously this test failed (https://gitlab.com/gitlab-org/gitlab/-/jobs/2948421534):

FOSS_ONLY=1 bundle exec rspec ./spec/controllers/projects/merge_requests_controller_spec.rb

MR acceptance checklist

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

Edited by Stan Hu

Merge request reports

Loading