From 6a6c6ca2075dae9c4f6ce984e275494f03682ee9 Mon Sep 17 00:00:00 2001 From: Ashik Salman Date: Tue, 18 May 2021 16:29:34 +0530 Subject: [PATCH] Added more regression for activejob Range serializer. --- activejob/lib/active_job/serializers/range_serializer.rb | 6 ++---- activejob/test/cases/argument_serialization_test.rb | 5 +++++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/activejob/lib/active_job/serializers/range_serializer.rb b/activejob/lib/active_job/serializers/range_serializer.rb index 15ed68b4f9..3d21c251fe 100644 --- a/activejob/lib/active_job/serializers/range_serializer.rb +++ b/activejob/lib/active_job/serializers/range_serializer.rb @@ -7,13 +7,11 @@ module ActiveJob def serialize(range) args = Arguments.serialize([range.begin, range.end, range.exclude_end?]) - hash = KEYS.zip(args).to_h - super(hash) + super(KEYS.zip(args).to_h) end def deserialize(hash) - args = Arguments.deserialize(hash.values_at(*KEYS)) - Range.new(*args) + klass.new(*Arguments.deserialize(hash.values_at(*KEYS))) end private diff --git a/activejob/test/cases/argument_serialization_test.rb b/activejob/test/cases/argument_serialization_test.rb index 5ef8d224e4..af84684b63 100644 --- a/activejob/test/cases/argument_serialization_test.rb +++ b/activejob/test/cases/argument_serialization_test.rb @@ -35,9 +35,14 @@ class ArgumentSerializationTest < ActiveSupport::TestCase 1..., 1..5, 1...5, + "a".."z", + "A".."Z", Date.new(2001, 2, 3).., + 10.days.ago..Date.today, Time.new(2002, 10, 31, 2, 2, 2.123456789r, "+02:00").., + 10.hours.ago..Time.current, DateTime.new(2001, 2, 3, 4, 5, 6.123456r, "+03:00").., + (DateTime.current - 4.weeks)..DateTime.current, ActiveSupport::TimeWithZone.new(Time.utc(1999, 12, 31, 23, 59, "59.123456789".to_r), ActiveSupport::TimeZone["UTC"]).., ].each do |arg| test "serializes #{arg.class} - #{arg.inspect} verbatim" do