1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Added more regression for activejob Range serializer.

This commit is contained in:
Ashik Salman 2021-05-18 16:29:34 +05:30
parent 179d0a1f47
commit 6a6c6ca207
2 changed files with 7 additions and 4 deletions

View file

@ -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

View file

@ -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