diff options
author | Jeremy Kemper <jeremykemper@gmail.com> | 2014-09-14 19:34:17 -0700 |
---|---|---|
committer | Jeremy Kemper <jeremykemper@gmail.com> | 2014-09-25 10:00:19 -0700 |
commit | 3f1d04e3bb04d240792112b5b45a9062c72e0df4 (patch) | |
tree | b7843061a6b5149d405a93ec30d642851fb0d3a4 /activejob/test/cases/argument_serialization_test.rb | |
parent | 391cfc20546049e056b99f8e47be92799412ef78 (diff) | |
download | rails-3f1d04e3bb04d240792112b5b45a9062c72e0df4.tar.gz rails-3f1d04e3bb04d240792112b5b45a9062c72e0df4.tar.bz2 rails-3f1d04e3bb04d240792112b5b45a9062c72e0df4.zip |
Fix string/gid collision in job arguments
Serialize Global IDs as special objects, distinguishable from Strings
Diffstat (limited to 'activejob/test/cases/argument_serialization_test.rb')
-rw-r--r-- | activejob/test/cases/argument_serialization_test.rb | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/activejob/test/cases/argument_serialization_test.rb b/activejob/test/cases/argument_serialization_test.rb index 5a46c5cdef..dbe36fc572 100644 --- a/activejob/test/cases/argument_serialization_test.rb +++ b/activejob/test/cases/argument_serialization_test.rb @@ -31,12 +31,12 @@ class ArgumentSerializationTest < ActiveSupport::TestCase end test 'should convert records to Global IDs' do - assert_arguments_roundtrip [@person], [@person.to_gid.to_s] + assert_arguments_roundtrip [@person], ['_aj_globalid' => @person.to_gid.to_s] end test 'should dive deep into arrays and hashes' do - assert_arguments_roundtrip [3, [@person]], [3, [@person.to_gid.to_s]] - assert_arguments_roundtrip [{ 'a' => @person }], [{ 'a' => @person.to_gid.to_s }.with_indifferent_access] + assert_arguments_roundtrip [3, [@person]], [3, ['_aj_globalid' => @person.to_gid.to_s]] + assert_arguments_roundtrip [{ 'a' => @person }], [{ 'a' => { '_aj_globalid' => @person.to_gid.to_s }}.with_indifferent_access] end test 'should stringify symbol hash keys' do @@ -51,6 +51,14 @@ class ArgumentSerializationTest < ActiveSupport::TestCase assert_raises ActiveJob::SerializationError do ActiveJob::Arguments.serialize [ { :a => [{ 2 => 3 }] } ] end + + assert_raises ActiveJob::SerializationError do + ActiveJob::Arguments.serialize [ '_aj_globalid' => 1 ] + end + + assert_raises ActiveJob::SerializationError do + ActiveJob::Arguments.serialize [ :_aj_globalid => 1 ] + end end test 'should not allow non-primitive objects' do |