Fix failing context aware spec
What does this MR do?
When running bundle exec rspec spec/services/ci/pipeline_trigger_service_spec.rb spec/lib/gitlab/sidekiq_queue_spec.rb
together, we get this spec failure: #326547 (closed).
The cause is a missing :context_aware
flag in spec/services/ci/pipeline_trigger_service_spec.rb
, because it calls code which changes the Gitlab::ApplicationContext
, which is tested by spec/lib/gitlab/sidekiq_queue_spec.rb
.
We can prevent a leaking application context by annotating a spec that calls Gitlab::ApplicationContext.push
with a :context_aware
flag.
Note that we used to wrap each spec in its own Labkit::Context
. Because this added overhead for all tests and creating a fresh context is unnecessary for mosts tests, we removed that here. Currently we control wrapping controller
, request
, feature
and context_aware
annotated tests or just context_aware
annotated tests with a fresh context with an environment variable (SKIP_RSPEC_CONTEXT_WRAPPING
). Setting that variable to false won't fix this error, since the Ci::PipelineTriggerService
spec is a service.
This MR adds the missing flag.
Screenshots (strongly suggested)
Does this MR meet the acceptance criteria?
Conformity
-
📋 Does this MR need a changelog?-
I have included a changelog entry. -
I have not included a changelog entry because no user facing changes.
-
-
Documentation (if required) -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers -
Informed Infrastructure department of a default or new setting change, if applicable per definition of done
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