discourse/spec/components/sidekiq/pausable_spec.rb

37 lines
709 B
Ruby
Raw Normal View History

require 'rails_helper'
require_dependency 'sidekiq/pausable'
describe Sidekiq do
after do
Sidekiq.unpause!
end
it "can pause and unpause" do
2014-08-19 06:57:34 -04:00
Sidekiq.pause!
2015-01-09 11:34:37 -05:00
expect(Sidekiq.paused?).to eq(true)
2014-08-19 06:57:34 -04:00
Sidekiq.unpause!
2015-01-09 11:34:37 -05:00
expect(Sidekiq.paused?).to eq(false)
end
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
end