File tree Expand file tree Collapse file tree 3 files changed +16
-9
lines changed Expand file tree Collapse file tree 3 files changed +16
-9
lines changed Original file line number Diff line number Diff line change
1
+ * Preserve full-precision ` enqueued_at ` timestamps for serialized jobs,
2
+ allowing more accurate reporting of how long a job spent waiting in the
3
+ queue before it was performed.
4
+
5
+ Retains IS08601 format compatibility.
6
+
7
+ * Jeremy Daer*
8
+
1
9
* Add ` --parent ` option to job generator to specify parent class of job.
2
10
3
11
Example:
Original file line number Diff line number Diff line change @@ -113,7 +113,7 @@ def serialize
113
113
"exception_executions" => exception_executions ,
114
114
"locale" => I18n . locale . to_s ,
115
115
"timezone" => timezone ,
116
- "enqueued_at" => Time . now . utc . iso8601
116
+ "enqueued_at" => Time . now . utc . iso8601 ( 9 )
117
117
}
118
118
end
119
119
Original file line number Diff line number Diff line change @@ -65,14 +65,13 @@ class JobSerializationTest < ActiveSupport::TestCase
65
65
end
66
66
end
67
67
68
- test "serialize stores the enqueued_at time" do
69
- h1 = HelloJob . new
70
- type = h1 . serialize [ "enqueued_at" ] . class
71
- assert_equal String , type
68
+ test "serializes enqueued_at with full precision" do
69
+ freeze_time
72
70
73
- h2 = HelloJob . deserialize ( h1 . serialize )
74
- # We should be able to parse a timestamp
75
- type = Time . parse ( h2 . enqueued_at ) . class
76
- assert_equal Time , type
71
+ serialized = HelloJob . new . serialize
72
+ assert_kind_of String , serialized [ "enqueued_at" ]
73
+
74
+ enqueued_at = HelloJob . deserialize ( serialized ) . enqueued_at
75
+ assert_equal Time . now . utc , Time . iso8601 ( enqueued_at )
77
76
end
78
77
end
You can’t perform that action at this time.
0 commit comments