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

Merge pull request #42250 from ashiksp/range-serializer

Added more regression for activejob Range serializer.
This commit is contained in:
Andrew White 2021-05-18 12:17:45 +01:00 committed by GitHub
commit a34d64d82e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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