Skip to content

Fix let_it_be usage in nuget_packages_spec.rb

What does this MR do?

During the maintainer review of !24182 (merged), it has been discussed that nuget_packages_spec.rb was using let_it_be(:project) in a non straightforward way: before/after callbacks were still needed in the examples.

This MR aims to fix that. We still keep let_it_be for faster test execution times but with reload: true. This way, the project gets project.reload between examples and we can drop all the after callbacks.

Detailed explanations:

  • nuget_packages_spec heavily use table based tests to check different user permissions and different project visibilities. See https://gitlab.com/gitlab-org/gitlab/-/blob/master/ee/spec/requests/api/nuget_packages_spec.rb#L101-120 for an example.
  • the project object is created by let_it_be in a public visibility. A before callback is used to set the correct visibility expected by the example.
  • Previously, a after callback was used to put back the public visibility. With this MR, this is no longer necessary as let_it_be(:project, reload: true) will automatically call project.reload after each example and thus rollback the visibility to public.

See !24182 (comment 287345202) and #205595 (closed)

Screenshots

n/a

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team
Edited by David Fernandez

Merge request reports