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

prevent args being misused

This commit is contained in:
Karl Freeman 2013-01-05 09:32:05 +00:00
parent 633983ae86
commit 224a2bf93e
2 changed files with 5 additions and 0 deletions

View file

@ -118,6 +118,7 @@ module Sidekiq
def self.normalize_item(item)
raise(ArgumentError, "Message must be a Hash of the form: { 'class' => SomeWorker, 'args' => ['bob', 1, :foo => 'bar'] }") unless item.is_a?(Hash)
raise(ArgumentError, "Message must include a class and set of arguments: #{item.inspect}") if !item['class'] || !item['args']
raise(ArgumentError, "Message args must be an Array") unless item['args'].is_a?(Array)
raise(ArgumentError, "Message class must be either a Class or String representation of the class name") unless item['class'].is_a?(Class) || item['class'].is_a?(String)
if item['class'].is_a?(Class)

View file

@ -39,6 +39,10 @@ class TestClient < MiniTest::Unit::TestCase
Sidekiq::Client.push('queue' => 'foo', 'class' => 42, 'args' => [1, 2])
end
assert_raises ArgumentError do
Sidekiq::Client.push('queue' => 'foo', 'class' => MyWorker, 'args' => 1)
end
end
it 'pushes messages to redis' do