mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Explicitly call #to_s when serializing GlobalID. Addresses #95
This commit is contained in:
parent
c15d24e56d
commit
261e51b0ca
2 changed files with 5 additions and 5 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue