Skip to content

Require internal gem `gitlab/safe_request_store` in middleware spec

Peter Leitzen requested to merge pl-fast-spec-safe-request-store into master

What does this MR do and why?

Because fast_spec_helper does not load all gems we need to load gems/gitlab-safe_request_store in order to make the spec pass when running standalone.

This isn't an issue in CI because it's running with spec_helper which loads all the gems 💎.

How to set up and validate locally

This branch

$ bin/rspec spec/lib/gitlab/middleware/webhook_recursion_detection_spec.rb
Run options: include {:focus=>true}

All examples were filtered out; ignoring {:focus=>true}

Gitlab::Middleware::WebhookRecursionDetection
  #call
    when the recursion detection header is present
Missing metadata feature_category: ./spec/lib/gitlab/middleware/webhook_recursion_detection_spec.rb:24 See https://docs.gitlab.com/ee/development/testing_guide/best_practices.html#feature-category-metadata
      sets the request UUID from the header
    when recursion headers are not present
Missing metadata feature_category: ./spec/lib/gitlab/middleware/webhook_recursion_detection_spec.rb:33 See https://docs.gitlab.com/ee/development/testing_guide/best_practices.html#feature-category-metadata
      works without errors

Finished in 0.05251 seconds (files took 1.23 seconds to load)
2 examples, 0 failures

On master

$ bin/rspec spec/lib/gitlab/middleware/webhook_recursion_detection_spec.rb
Run options: include {:focus=>true}

All examples were filtered out; ignoring {:focus=>true}

Gitlab::Middleware::WebhookRecursionDetection
  #call
    when the recursion detection header is present
      sets the request UUID from the header (FAILED - 1)
    when recursion headers are not present
      works without errors (FAILED - 2)

Failures:

  1) Gitlab::Middleware::WebhookRecursionDetection#call when the recursion detection header is present sets the request UUID from the header
     Failure/Error: Gitlab::SafeRequestStore.ensure_request_store { example.run }

     NoMethodError:
       undefined method `ensure_request_store' for Gitlab::SafeRequestStore:Module

           Gitlab::SafeRequestStore.ensure_request_store { example.run }
                                   ^^^^^^^^^^^^^^^^^^^^^
     # ./spec/lib/gitlab/middleware/webhook_recursion_detection_spec.rb:14:in `block (2 levels) in <top (required)>'
     # ./spec/support/system_exit_detected.rb:7:in `block (2 levels) in <top (required)>'

  2) Gitlab::Middleware::WebhookRecursionDetection#call when recursion headers are not present works without errors
     Failure/Error: Gitlab::SafeRequestStore.ensure_request_store { example.run }

     NoMethodError:
       undefined method `ensure_request_store' for Gitlab::SafeRequestStore:Module

           Gitlab::SafeRequestStore.ensure_request_store { example.run }
                                   ^^^^^^^^^^^^^^^^^^^^^
     # ./spec/lib/gitlab/middleware/webhook_recursion_detection_spec.rb:14:in `block (2 levels) in <top (required)>'
     # ./spec/support/system_exit_detected.rb:7:in `block (2 levels) in <top (required)>'

Finished in 0.00121 seconds (files took 1.3 seconds to load)
2 examples, 2 failures

Failed examples:

rspec ./spec/lib/gitlab/middleware/webhook_recursion_detection_spec.rb:24 # Gitlab::Middleware::WebhookRecursionDetection#call when the recursion detection header is present sets the request UUID from the header
rspec ./spec/lib/gitlab/middleware/webhook_recursion_detection_spec.rb:33 # Gitlab::Middleware::WebhookRecursionDetection#call when recursion headers are not present works without errors

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 Peter Leitzen

Merge request reports