Skip to content
Browse files

Explicitly call #to_s when serializing GlobalID. Addresses #95

  • Loading branch information...
1 parent c15d24e commit 261e51b0caca4e1dfa08f9a398df407933fd9650 @miyagawa miyagawa committed
Showing with 5 additions and 5 deletions.
  1. +1 −1 lib/active_job/arguments.rb
  2. +4 −4 test/cases/parameters_test.rb
View
2 lib/active_job/arguments.rb
@@ -17,7 +17,7 @@ def self.deserialize(arguments)
def self.serialize_argument(argument)
case argument
when ActiveModel::GlobalIdentification
- argument.global_id
+ argument.global_id.to_s
when *TYPE_WHITELIST
argument
when Array
View
8 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

0 comments on commit 261e51b

Please sign in to comment.
Something went wrong with that request. Please try again.