From 69c9d66740b3ad6d10d46361b116cd323614289a Mon Sep 17 00:00:00 2001 From: Mike Perham Date: Wed, 9 Mar 2016 09:39:10 -0800 Subject: [PATCH] Verify JSON round trip symmetry of arguments, #2870 We can't do this today because ActiveJob in Rails 4 is not symmetric. https://github.com/rails/rails/pull/24123 --- lib/sidekiq/client.rb | 1 + test/test_testing_inline.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/sidekiq/client.rb b/lib/sidekiq/client.rb index 3d9941d1..01b52951 100644 --- a/lib/sidekiq/client.rb +++ b/lib/sidekiq/client.rb @@ -205,6 +205,7 @@ module Sidekiq raise(ArgumentError, "Job must be a Hash with 'class' and 'args' keys: { 'class' => SomeWorker, 'args' => ['bob', 1, :foo => 'bar'] }") unless item.is_a?(Hash) && item.has_key?('class'.freeze) && item.has_key?('args'.freeze) raise(ArgumentError, "Job args must be an Array") unless item['args'].is_a?(Array) raise(ArgumentError, "Job class must be either a Class or String representation of the class name") unless item['class'.freeze].is_a?(Class) || item['class'.freeze].is_a?(String) + #raise(ArgumentError, "Arguments must be native JSON types, see https://github.com/mperham/sidekiq/wiki/Best-Practices") unless JSON.load(JSON.dump(item['args'])) == item['args'] normalized_hash(item['class'.freeze]) .each{ |key, value| item[key] = value if item[key].nil? } diff --git a/test/test_testing_inline.rb b/test/test_testing_inline.rb index e26253c0..57b5f89c 100644 --- a/test/test_testing_inline.rb +++ b/test/test_testing_inline.rb @@ -86,7 +86,7 @@ class TestInline < Sidekiq::Test end it 'should relay parameters through json' do - assert Sidekiq::Client.enqueue(InlineWorkerWithTimeParam, Time.now) + assert Sidekiq::Client.enqueue(InlineWorkerWithTimeParam, Time.now.to_f) end end