[rspec] Consider ensuring that a current organization is available in test context

For request layer specs, we have a shared context with_current_organization. It stubs the Gitlab::Current::Organization.organization method so Current.organization will be set in tests

If we start to be more dependent on existing of a Current Organization, we will need this more often. This means developer need to add with_current_organization when needed. But this will be needed for almost all web requests, especially if we start to implement organization isolation.

Proposal:

Enable this context for type: controller (and other request layer types)

Implementation guide

We can change this incrementally, with one merge request per spec type. This will keep the MRs focused and easier to review.

  • MR 0: Mock Current.organization and not Gitlab::Current::Organization
  • MR 1: Enable with_current_organization for type: :controller specs and fix all resulting failures
  • MR 2: Enable with_current_organization for type: :request specs and fix all resulting failures
  • MR 3: Enable with_current_organization for type: :feature specs and fix all resulting failures
  • MR 4: Enable with_current_organization for graphql resolvers
Edited by Rutger Wessels