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

raise ArgumentError if 'at' size is wrong ()

In `Sidekiq::Client.bulk_push`, now
'at' size must be the same size as
'args' (or just be a single numeric).

Fixes 
This commit is contained in:
Ulysse Buonomo 2020-06-18 16:33:13 +02:00 committed by GitHub
parent 4338695727
commit 50b9e67655
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 0 deletions

View file

@ -96,6 +96,7 @@ module Sidekiq
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' Array must have same size as 'args' Array" if at.is_a?(Array) && at.size != args.size
normed = normalize_item(items)
payloads = args.map.with_index { |job_args, index|

View file

@ -168,6 +168,14 @@ describe Sidekiq::Client do
assert_raises ArgumentError do
Sidekiq::Client.push_bulk('class' => 'QueuedWorker', 'args' => [[1], [2]], 'at' => [Time.now.to_f, :not_a_numeric])
end
assert_raises ArgumentError do
Sidekiq::Client.push_bulk('class' => QueuedWorker, 'args' => [[1], [2]], 'at' => [Time.now.to_f])
end
assert_raises ArgumentError do
Sidekiq::Client.push_bulk('class' => QueuedWorker, 'args' => [[1]], 'at' => [Time.now.to_f, Time.now.to_f])
end
end
end
end