aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@basecamp.com>2014-07-03 13:57:51 -0500
committerDavid Heinemeier Hansson <david@basecamp.com>2014-07-03 13:57:51 -0500
commit2c31b1832f440d0eb7c5db51d11630e885d0a824 (patch)
tree77aa768615dc40f13010253cb5188c8d96400bde
parentb24b7b9b76fa59eeddeb91b32b24d52e17f19a16 (diff)
parent261e51b0caca4e1dfa08f9a398df407933fd9650 (diff)
downloadrails-2c31b1832f440d0eb7c5db51d11630e885d0a824.tar.gz
rails-2c31b1832f440d0eb7c5db51d11630e885d0a824.tar.bz2
rails-2c31b1832f440d0eb7c5db51d11630e885d0a824.zip
Merge pull request #96 from miyagawa/seiralize_globalid
Call #to_s when serializing GlobalID. Fix #95
-rw-r--r--lib/active_job/arguments.rb2
-rw-r--r--test/cases/parameters_test.rb8
2 files changed, 5 insertions, 5 deletions
diff --git a/lib/active_job/arguments.rb b/lib/active_job/arguments.rb
index ba314ccf14..ef6a3fce1d 100644
--- a/lib/active_job/arguments.rb
+++ b/lib/active_job/arguments.rb
@@ -17,7 +17,7 @@ module ActiveJob
def self.serialize_argument(argument)
case argument
when ActiveModel::GlobalIdentification
- argument.global_id
+ argument.global_id.to_s
when *TYPE_WHITELIST
argument
when Array
diff --git a/test/cases/parameters_test.rb b/test/cases/parameters_test.rb
index 737f3c26b7..76e8a8059a 100644
--- a/test/cases/parameters_test.rb
+++ b/test/cases/parameters_test.rb
@@ -26,8 +26,8 @@ class ParameterSerializationTest < ActiveSupport::TestCase
end
test 'should dive deep into arrays or hashes' do
- assert_equal [ { "a" => Person.find(5).gid }.with_indifferent_access ], ActiveJob::Arguments.serialize([ { a: Person.find(5) } ])
- assert_equal [ [ Person.find(5).gid ] ], ActiveJob::Arguments.serialize([ [ Person.find(5) ] ])
+ assert_equal [ { "a" => Person.find(5).gid.to_s }.with_indifferent_access ], ActiveJob::Arguments.serialize([ { a: Person.find(5) } ])
+ assert_equal [ [ Person.find(5).gid.to_s ] ], ActiveJob::Arguments.serialize([ [ Person.find(5) ] ])
end
test 'should dive deep into arrays or hashes and raise exception on complex objects' do
@@ -45,11 +45,11 @@ class ParameterSerializationTest < ActiveSupport::TestCase
end
test 'should serialize records with global id' do
- assert_equal [ Person.find(5).gid ], ActiveJob::Arguments.serialize([ Person.find(5) ])
+ assert_equal [ Person.find(5).gid.to_s ], ActiveJob::Arguments.serialize([ Person.find(5) ])
end
test 'should serialize values and records together' do
- assert_equal [ 3, Person.find(5).gid ], ActiveJob::Arguments.serialize([ 3, Person.find(5) ])
+ assert_equal [ 3, Person.find(5).gid.to_s ], ActiveJob::Arguments.serialize([ 3, Person.find(5) ])
end
end