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 ...@@ -27,7 +27,7 @@ RSpec.describe UpdateAllMirrorsWorker do
worker.perform worker.perform
end 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 inner_context = nil
outer_context = nil outer_context = nil
......
...@@ -78,13 +78,8 @@ RSpec.describe Gitlab::Profiler do ...@@ -78,13 +78,8 @@ RSpec.describe Gitlab::Profiler do
end end
it 'strips out the private token' do it 'strips out the private token' do
expect(custom_logger).to receive(:add) do |severity, _progname, message| allow(custom_logger).to receive(:add).and_call_original
next if message.include?('spec/') expect(custom_logger).to receive(:add).with(Logger::DEBUG, anything, 'public [FILTERED]').at_least(1)
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
custom_logger.debug("public #{private_token}") custom_logger.debug("public #{private_token}")
end end
......
...@@ -11,7 +11,7 @@ RSpec.describe Ci::PipelineTriggerService do ...@@ -11,7 +11,7 @@ RSpec.describe Ci::PipelineTriggerService do
stub_ci_pipeline_to_return_yaml_file stub_ci_pipeline_to_return_yaml_file
end end
describe '#execute', :context_aware do describe '#execute' do
let_it_be(:user) { create(:user) } let_it_be(:user) { create(:user) }
let(:result) { described_class.new(project, user, params).execute } let(:result) { described_class.new(project, user, params).execute }
......
...@@ -338,20 +338,10 @@ RSpec.configure do |config| ...@@ -338,20 +338,10 @@ RSpec.configure do |config|
RequestStore.clear! RequestStore.clear!
end end
if ENV['SKIP_RSPEC_CONTEXT_WRAPPING'] config.around do |example|
config.around(:example, :context_aware) do |example| # Wrap each example in it's own context to make sure the contexts don't
# Wrap each example in it's own context to make sure the contexts don't # leak
# leak Gitlab::ApplicationContext.with_raw_context { example.run }
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
end end
config.around do |example| config.around do |example|
......
# frozen_string_literal: true # frozen_string_literal: true
RSpec.shared_examples 'API::CI::Runner application context metadata' do |api_route| 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 # Avoids popping the context from the thread so we can
# check its content after the request. # check its content after the request.
allow(Labkit::Context).to receive(:pop) allow(Labkit::Context).to receive(:pop)
......
# frozen_string_literal: true # frozen_string_literal: true
RSpec.shared_examples 'storing arguments in the application context' do 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 # Stub the clearing of the context so we can validate it later
allow(Labkit::Context).to receive(:pop) 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