Commit 9c826440 authored by Nick Thomas's avatar Nick Thomas

Merge branch 're-add-context-wrapping-for-specs' into 'master'

Re-add application context wrapping

See merge request gitlab-org/gitlab!58749
parents 6d72f39c a9b32f61
......@@ -27,7 +27,7 @@ RSpec.describe UpdateAllMirrorsWorker do
worker.perform
end
it 'removes metadata except correlation_id from the application context before scheduling mirrors', :context_aware do
it 'removes metadata except correlation_id from the application context before scheduling mirrors' do
inner_context = nil
outer_context = nil
......
......@@ -78,13 +78,8 @@ RSpec.describe Gitlab::Profiler do
end
it 'strips out the private token' do
expect(custom_logger).to receive(:add) do |severity, _progname, message|
next if message.include?('spec/')
expect(severity).to eq(Logger::DEBUG)
expect(message).to include('public').and include(described_class::FILTERED_STRING)
expect(message).not_to include(private_token)
end.at_least(1) # This spec could be wrapped in more blocks in the future
allow(custom_logger).to receive(:add).and_call_original
expect(custom_logger).to receive(:add).with(Logger::DEBUG, anything, 'public [FILTERED]').at_least(1)
custom_logger.debug("public #{private_token}")
end
......
......@@ -11,7 +11,7 @@ RSpec.describe Ci::PipelineTriggerService do
stub_ci_pipeline_to_return_yaml_file
end
describe '#execute', :context_aware do
describe '#execute' do
let_it_be(:user) { create(:user) }
let(:result) { described_class.new(project, user, params).execute }
......
......@@ -338,20 +338,10 @@ RSpec.configure do |config|
RequestStore.clear!
end
if ENV['SKIP_RSPEC_CONTEXT_WRAPPING']
config.around(:example, :context_aware) do |example|
# Wrap each example in it's own context to make sure the contexts don't
# leak
Gitlab::ApplicationContext.with_raw_context { example.run }
end
else
config.around do |example|
if [:controller, :request, :feature].include?(example.metadata[:type]) || example.metadata[:context_aware]
Gitlab::ApplicationContext.with_raw_context { example.run }
else
example.run
end
end
config.around do |example|
# Wrap each example in it's own context to make sure the contexts don't
# leak
Gitlab::ApplicationContext.with_raw_context { example.run }
end
config.around do |example|
......
# frozen_string_literal: true
RSpec.shared_examples 'API::CI::Runner application context metadata' do |api_route|
it 'contains correct context metadata', :context_aware do
it 'contains correct context metadata' do
# Avoids popping the context from the thread so we can
# check its content after the request.
allow(Labkit::Context).to receive(:pop)
......
# frozen_string_literal: true
RSpec.shared_examples 'storing arguments in the application context' do
it 'places the expected params in the application context', :context_aware do
it 'places the expected params in the application context' do
# Stub the clearing of the context so we can validate it later
allow(Labkit::Context).to receive(:pop)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment