Skip to content

Commit 6d31f1a

Browse files
committed
Replace deprecated Sidekiq testing API with new Sidekiq 8.1+ API
`require "sidekiq/testing"` is deprecated and will be removed in Sidekiq 9.0. The new API makes test mode activation explicit: - `require 'sidekiq/testing'` → `Sidekiq.testing!(:fake)` - `Sidekiq::Testing.inline! { }` → `Sidekiq.testing!(:inline) { }`
1 parent 6f4beeb commit 6d31f1a

6 files changed

Lines changed: 20 additions & 13 deletions

File tree

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## master (unreleased)
4+
5+
### Changes
6+
7+
* Replace deprecated `Sidekiq::Testing` API with new `Sidekiq 8.1+` testing API. ([@mattmenefee][])
8+
39
## 8.0.1 (2026-03-12)
410

511
### New Features
@@ -873,6 +879,7 @@
873879
[@MarkMurphy]: https://github.com/MarkMurphy
874880
[@marshall]: https://github.com/marshall
875881
[@matchbookmac]: https://github.com/matchbookmac
882+
[@mattmenefee]: https://github.com/mattmenefee
876883
[@matthee]: https://github.com/matthee
877884
[@mattzollinhofer]: https://github.com/mattzollinhofer
878885
[@menglewis]: https://github.com/menglewis

spec/chewy/strategy/delayed_sidekiq/scheduler_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
require 'spec_helper'
22

33
if defined?(Sidekiq)
4-
require 'sidekiq/testing'
4+
Sidekiq.testing!(:fake)
55

66
describe Chewy::Strategy::DelayedSidekiq::Scheduler do
77
before do

spec/chewy/strategy/delayed_sidekiq/worker_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
require 'spec_helper'
22

33
if defined?(Sidekiq)
4-
require 'sidekiq/testing'
4+
Sidekiq.testing!(:fake)
55
require 'redis'
66

77
describe Chewy::Strategy::DelayedSidekiq::Worker do

spec/chewy/strategy/delayed_sidekiq_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
require 'spec_helper'
22

33
if defined?(Sidekiq)
4-
require 'sidekiq/testing'
4+
Sidekiq.testing!(:fake)
55
require 'redis'
66

77
describe Chewy::Strategy::DelayedSidekiq do
@@ -73,7 +73,7 @@
7373

7474
expect($stdout).not_to receive(:puts)
7575

76-
Sidekiq::Testing.inline! do
76+
Sidekiq.testing!(:inline) do
7777
expect { [city, other_city].map(&:save!) }
7878
.to update_index(CitiesIndex, strategy: :delayed_sidekiq)
7979
.and_reindex(city, other_city).only
@@ -114,7 +114,7 @@ def expected_at_time
114114

115115
expect($stdout).to receive(:puts).with('hello') # check that reindex_wrapper works
116116

117-
Sidekiq::Testing.inline! do
117+
Sidekiq.testing!(:inline) do
118118
expect { [city, other_city].map(&:save!) }
119119
.to update_index(CitiesIndex, strategy: :delayed_sidekiq)
120120
.and_reindex(city, other_city).only

spec/chewy/strategy/lazy_sidekiq_spec.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
require 'spec_helper'
22

33
if defined?(Sidekiq)
4-
require 'sidekiq/testing'
4+
Sidekiq.testing!(:fake)
55

66
describe Chewy::Strategy::LazySidekiq do
77
around do |example|
@@ -39,7 +39,7 @@
3939
))
4040
.and_call_original
4141
.once
42-
Sidekiq::Testing.inline! do
42+
Sidekiq.testing!(:inline) do
4343
expect { [city, other_city].map(&:save!) }
4444
.to update_index(CitiesIndex, strategy: :lazy_sidekiq)
4545
.and_reindex(city, other_city).only
@@ -60,7 +60,7 @@
6060
))
6161
.and_call_original
6262
.once
63-
Sidekiq::Testing.inline! do
63+
Sidekiq.testing!(:inline) do
6464
expect { [city, other_city].map(&:destroy) }.to update_index(CitiesIndex, strategy: :sidekiq)
6565
end
6666
end
@@ -71,7 +71,7 @@
7171
expect(other_city).to receive(:run_chewy_callbacks).and_call_original
7272

7373
expect do
74-
Sidekiq::Testing.inline! do
74+
Sidekiq.testing!(:inline) do
7575
Chewy::Strategy::LazySidekiq::IndicesUpdateWorker.new.perform({'City' => [city.id, other_city.id]})
7676
end
7777
end.to update_index(CitiesIndex).and_reindex(city, other_city).only
@@ -88,7 +88,7 @@
8888
expect(other_city).to receive(:run_chewy_callbacks).and_call_original
8989

9090
expect do
91-
Sidekiq::Testing.inline! do
91+
Sidekiq.testing!(:inline) do
9292
Chewy::Strategy::LazySidekiq::IndicesUpdateWorker.new.perform({'City' => [city.id, other_city.id]})
9393
end
9494
end.to update_index(CitiesIndex).and_reindex(city, other_city).only.no_refresh
@@ -97,7 +97,7 @@
9797
end
9898

9999
context 'integration' do
100-
around { |example| Sidekiq::Testing.inline! { example.run } }
100+
around { |example| Sidekiq.testing!(:inline) { example.run } }
101101

102102
let(:update_condition) { true }
103103

spec/chewy/strategy/sidekiq_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
require 'spec_helper'
22

33
if defined?(Sidekiq)
4-
require 'sidekiq/testing'
4+
Sidekiq.testing!(:fake)
55

66
describe Chewy::Strategy::Sidekiq do
77
around do |example|
@@ -31,7 +31,7 @@
3131

3232
specify do
3333
expect(Sidekiq::Client).to receive(:push).with(hash_including('queue' => 'low')).and_call_original
34-
Sidekiq::Testing.inline! do
34+
Sidekiq.testing!(:inline) do
3535
expect { [city, other_city].map(&:save!) }
3636
.to update_index(CitiesIndex, strategy: :sidekiq)
3737
.and_reindex(city, other_city).only

0 commit comments

Comments
 (0)