diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-20 18:38:24 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-20 18:38:24 +0000 |
commit | 983a0bba5d2a042c4a3bbb22432ec192c7501d82 (patch) | |
tree | b153cd387c14ba23bd5a07514c7c01fddf6a78a0 /spec/lib/marginalia_spec.rb | |
parent | a2bddee2cdb38673df0e004d5b32d9f77797de64 (diff) | |
download | gitlab-ce-983a0bba5d2a042c4a3bbb22432ec192c7501d82.tar.gz |
Add latest changes from gitlab-org/gitlab@12-10-stable-ee
Diffstat (limited to 'spec/lib/marginalia_spec.rb')
-rw-r--r-- | spec/lib/marginalia_spec.rb | 30 |
1 files changed, 6 insertions, 24 deletions
diff --git a/spec/lib/marginalia_spec.rb b/spec/lib/marginalia_spec.rb index d4b84c5cdc4..2f446694083 100644 --- a/spec/lib/marginalia_spec.rb +++ b/spec/lib/marginalia_spec.rb @@ -24,20 +24,6 @@ describe 'Marginalia spec' do end end - def add_sidekiq_middleware - # Reference: https://github.com/mperham/sidekiq/wiki/Testing#testing-server-middlewaresidekiq - # Sidekiq test harness fakes worker without its server middlewares, so include instrumentation to 'Sidekiq::Testing' server middleware. - Sidekiq::Testing.server_middleware do |chain| - chain.add Marginalia::SidekiqInstrumentation::Middleware - end - end - - def remove_sidekiq_middleware - Sidekiq::Testing.server_middleware do |chain| - chain.remove Marginalia::SidekiqInstrumentation::Middleware - end - end - def stub_feature(value) allow(Gitlab::Marginalia).to receive(:cached_feature_enabled?).and_return(value) end @@ -88,20 +74,16 @@ describe 'Marginalia spec' do end describe 'for Sidekiq worker jobs' do - before(:all) do - add_sidekiq_middleware - - # Because of faking, 'Sidekiq.server?' does not work so implicitly set application name which is done in config/initializers/0_marginalia.rb - Marginalia.application_name = "sidekiq" + around do |example| + with_sidekiq_server_middleware do |chain| + chain.add Marginalia::SidekiqInstrumentation::Middleware + Marginalia.application_name = "sidekiq" + example.run + end end after(:all) do MarginaliaTestJob.clear - remove_sidekiq_middleware - end - - around do |example| - Sidekiq::Testing.fake! { example.run } end before do |