diff options
Diffstat (limited to 'activejob/test')
-rw-r--r-- | activejob/test/cases/argument_serialization_test.rb | 2 | ||||
-rw-r--r-- | activejob/test/cases/serializers_test.rb | 21 |
2 files changed, 20 insertions, 3 deletions
diff --git a/activejob/test/cases/argument_serialization_test.rb b/activejob/test/cases/argument_serialization_test.rb index 8f51a2d238..4e26b9a178 100644 --- a/activejob/test/cases/argument_serialization_test.rb +++ b/activejob/test/cases/argument_serialization_test.rb @@ -14,7 +14,7 @@ class ArgumentSerializationTest < ActiveSupport::TestCase [ nil, 1, 1.0, 1_000_000_000_000_000_000_000, "a", true, false, BigDecimal.new(5), :a, 1.day, Date.new(2001, 2, 3), Time.new(2002, 10, 31, 2, 2, 2, "+02:00"), - DateTime.new(2001, 2, 3, 4, 5, 6, '+03:00'), + DateTime.new(2001, 2, 3, 4, 5, 6, "+03:00"), ActiveSupport::TimeWithZone.new(Time.utc(1999, 12, 31, 23, 59, 59), ActiveSupport::TimeZone["UTC"]), [ 1, "a" ], { "a" => 1 } diff --git a/activejob/test/cases/serializers_test.rb b/activejob/test/cases/serializers_test.rb index 207ae55b49..a86f168d03 100644 --- a/activejob/test/cases/serializers_test.rb +++ b/activejob/test/cases/serializers_test.rb @@ -58,7 +58,24 @@ class SerializersTest < ActiveSupport::TestCase test "won't deserialize unknown hash" do hash = { "_dummy_serializer" => 123, "_aj_symbol_keys" => [] } - assert_equal({ "_dummy_serializer" => 123 }, ActiveJob::Serializers.deserialize(hash)) + error = assert_raises(ArgumentError) do + ActiveJob::Serializers.deserialize(hash) + end + assert_equal( + 'Serializer name is not present in the argument: {"_dummy_serializer"=>123, "_aj_symbol_keys"=>[]}', + error.message + ) + end + + test "won't deserialize unknown serializer" do + hash = { "_aj_serialized" => "DoNotExist", "value" => 123 } + error = assert_raises(ArgumentError) do + ActiveJob::Serializers.deserialize(hash) + end + assert_equal( + "Serializer DoNotExist is not know", + error.message + ) end test "will deserialize know serialized objects" do @@ -74,7 +91,7 @@ class SerializersTest < ActiveSupport::TestCase test "can't add serializer with the same key twice" do ActiveJob::Serializers.add_serializers DummySerializer - assert_no_difference(-> { ActiveJob::Serializers.serializers.size } ) do + assert_no_difference(-> { ActiveJob::Serializers.serializers.size }) do ActiveJob::Serializers.add_serializers DummySerializer end end |