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:
commit
a34d64d82e
2 changed files with 7 additions and 4 deletions
|
@ -7,13 +7,11 @@ module ActiveJob
|
||||||
|
|
||||||
def serialize(range)
|
def serialize(range)
|
||||||
args = Arguments.serialize([range.begin, range.end, range.exclude_end?])
|
args = Arguments.serialize([range.begin, range.end, range.exclude_end?])
|
||||||
hash = KEYS.zip(args).to_h
|
super(KEYS.zip(args).to_h)
|
||||||
super(hash)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def deserialize(hash)
|
def deserialize(hash)
|
||||||
args = Arguments.deserialize(hash.values_at(*KEYS))
|
klass.new(*Arguments.deserialize(hash.values_at(*KEYS)))
|
||||||
Range.new(*args)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -35,9 +35,14 @@ class ArgumentSerializationTest < ActiveSupport::TestCase
|
||||||
1...,
|
1...,
|
||||||
1..5,
|
1..5,
|
||||||
1...5,
|
1...5,
|
||||||
|
"a".."z",
|
||||||
|
"A".."Z",
|
||||||
Date.new(2001, 2, 3)..,
|
Date.new(2001, 2, 3)..,
|
||||||
|
10.days.ago..Date.today,
|
||||||
Time.new(2002, 10, 31, 2, 2, 2.123456789r, "+02:00")..,
|
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.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"])..,
|
ActiveSupport::TimeWithZone.new(Time.utc(1999, 12, 31, 23, 59, "59.123456789".to_r), ActiveSupport::TimeZone["UTC"])..,
|
||||||
].each do |arg|
|
].each do |arg|
|
||||||
test "serializes #{arg.class} - #{arg.inspect} verbatim" do
|
test "serializes #{arg.class} - #{arg.inspect} verbatim" do
|
||||||
|
|
Loading…
Reference in a new issue