aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCristian Bica <cristian.bica@gmail.com>2014-06-03 00:54:07 +0300
committerCristian Bica <cristian.bica@gmail.com>2014-06-03 00:54:07 +0300
commita4a7f0279af91307a8b36a8c437c4734721741d6 (patch)
treeb4a1f3f8359c692082403a76d40df0304812a749
parentba3ae62a775182c663c6797e21618bb37de3aaba (diff)
downloadrails-a4a7f0279af91307a8b36a8c437c4734721741d6.tar.gz
rails-a4a7f0279af91307a8b36a8c437c4734721741d6.tar.bz2
rails-a4a7f0279af91307a8b36a8c437c4734721741d6.zip
Fixed Hash deserialisation
-rw-r--r--lib/active_job/arguments.rb2
-rw-r--r--test/cases/parameters_test.rb6
2 files changed, 6 insertions, 2 deletions
diff --git a/lib/active_job/arguments.rb b/lib/active_job/arguments.rb
index 6fe52397da..553ab20f65 100644
--- a/lib/active_job/arguments.rb
+++ b/lib/active_job/arguments.rb
@@ -28,7 +28,7 @@ module ActiveJob
when Array
deserialize(argument)
when Hash
- argument.with_indifferent_access
+ Hash[argument.map{ |key, value| [ key, deserialize([value]).first ] }].with_indifferent_access
else
ActiveModel::GlobalLocator.locate(argument) || argument
end
diff --git a/test/cases/parameters_test.rb b/test/cases/parameters_test.rb
index 93b34278a5..737f3c26b7 100644
--- a/test/cases/parameters_test.rb
+++ b/test/cases/parameters_test.rb
@@ -66,8 +66,12 @@ class ParameterDeserializationTest < ActiveSupport::TestCase
assert_equal [ 3, Person.find(5) ], ActiveJob::Arguments.deserialize([ 3, Person.find(5).gid ])
end
- test 'should dive deep when desierializing' do
+ test 'should dive deep when deserialising arrays' do
assert_equal [ [ 3, Person.find(5) ] ], ActiveJob::Arguments.deserialize([ [ 3, Person.find(5).gid ] ])
end
+ test 'should dive deep when deserialising hashes' do
+ assert_equal [ { "5" => Person.find(5) } ], ActiveJob::Arguments.deserialize([ { "5" => Person.find(5).gid } ])
+ end
+
end