1
0
Fork 0
mirror of https://github.com/mperham/sidekiq.git synced 2022-11-09 13:52:34 -05:00

updated Sidekiq::Client.push_bulk to support ActiveSupport::Duration in the at argument (#4996)

This commit is contained in:
Cameron McCord 2021-09-20 18:56:07 -06:00 committed by GitHub
parent a3b4fafdbb
commit e9d16dbdb8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View file

@ -95,7 +95,7 @@ module Sidekiq
return [] if args.empty? # no jobs to push
at = items.delete("at")
raise ArgumentError, "Job 'at' must be a Numeric or an Array of Numeric timestamps" if at && (Array(at).empty? || !Array(at).all?(Numeric))
raise ArgumentError, "Job 'at' must be a Numeric or an Array of Numeric timestamps" if at && (Array(at).empty? || !Array(at).all?{|entry| entry.is_a?(Numeric) })
raise ArgumentError, "Job 'at' Array must have same size as 'args' Array" if at.is_a?(Array) && at.size != args.size
normed = normalize_item(items)

View file

@ -148,6 +148,11 @@ describe Sidekiq::Client do
assert_equal second_at, Sidekiq::ScheduledSet.new.find_job(second_jid).at
end
it 'can push jobs scheduled using ActiveSupport::Duration' do
jids = Sidekiq::Client.push_bulk('class' => QueuedWorker, 'args' => [[1], [2]], 'at' => [1.seconds, 111.seconds])
assert_equal 2, jids.size
end
it 'returns the jids for the jobs' do
Sidekiq::Client.push_bulk('class' => 'QueuedWorker', 'args' => (1..2).to_a.map { |x| Array(x) }).each do |jid|
assert_match(/[0-9a-f]{12}/, jid)