2015-10-11 17:41:23 +08:00
|
|
|
require 'rails_helper'
|
2014-08-19 12:04:58 +08:00
|
|
|
require_dependency 'sidekiq/pausable'
|
|
|
|
|
|
|
|
describe Sidekiq do
|
2018-08-29 10:36:59 +08:00
|
|
|
after do
|
|
|
|
Sidekiq.unpause!
|
|
|
|
end
|
|
|
|
|
2014-08-19 12:04:58 +08:00
|
|
|
it "can pause and unpause" do
|
2014-08-19 18:57:34 +08:00
|
|
|
Sidekiq.pause!
|
2015-01-10 00:34:37 +08:00
|
|
|
expect(Sidekiq.paused?).to eq(true)
|
2014-08-19 18:57:34 +08:00
|
|
|
Sidekiq.unpause!
|
2015-01-10 00:34:37 +08:00
|
|
|
expect(Sidekiq.paused?).to eq(false)
|
2014-08-19 12:04:58 +08:00
|
|
|
end
|
2018-08-29 10:36:59 +08:00
|
|
|
|
|
|
|
it "can still run heartbeats when paused" do
|
|
|
|
Sidekiq.pause!
|
|
|
|
|
|
|
|
freeze_time 1.week.from_now
|
|
|
|
|
|
|
|
jobs = Sidekiq::ScheduledSet.new
|
|
|
|
|
|
|
|
Sidekiq::Testing.disable! do
|
|
|
|
jobs.clear
|
|
|
|
|
|
|
|
middleware = Sidekiq::Pausable.new
|
|
|
|
middleware.call(Jobs::RunHeartbeat.new, { "args" => [{}] }, "critical") do
|
|
|
|
"done"
|
|
|
|
end
|
|
|
|
|
|
|
|
jobs = Sidekiq::ScheduledSet.new
|
|
|
|
expect(jobs.size).to eq(0)
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
2014-08-19 12:04:58 +08:00
|
|
|
end
|