Skip to content

Commit 7982896

Browse files
committed
Remove deprecated support to set numeric values to scheduled_at attribute
1 parent 2a761d2 commit 7982896

File tree

5 files changed

+10
-38
lines changed

5 files changed

+10
-38
lines changed

activejob/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
* Remove deprecated support to set numeric values to `scheduled_at` attribute.
2+
3+
*Rafael Mendonça França*
4+
15
* Deprecate `Rails.application.config.active_job.use_big_decimal_serialize`.
26

37
*Rafael Mendonça França*

activejob/lib/active_job/core.rb

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ module Core
1313
attr_writer :serialized_arguments
1414

1515
# Time when the job should be performed
16-
attr_reader :scheduled_at
17-
18-
attr_reader :_scheduled_at_time # :nodoc:
16+
attr_accessor :scheduled_at
1917

2018
# Job Identifier
2119
attr_accessor :job_id
@@ -97,7 +95,6 @@ def initialize(*arguments)
9795
@job_id = SecureRandom.uuid
9896
@queue_name = self.class.queue_name
9997
@scheduled_at = nil
100-
@_scheduled_at_time = nil
10198
@priority = self.class.priority
10299
@executions = 0
103100
@exception_executions = {}
@@ -120,7 +117,7 @@ def serialize
120117
"locale" => I18n.locale.to_s,
121118
"timezone" => timezone,
122119
"enqueued_at" => Time.now.utc.iso8601(9),
123-
"scheduled_at" => _scheduled_at_time ? _scheduled_at_time.utc.iso8601(9) : nil,
120+
"scheduled_at" => scheduled_at ? scheduled_at.utc.iso8601(9) : nil,
124121
}
125122
end
126123

@@ -174,18 +171,6 @@ def set(options = {}) # :nodoc:
174171
self
175172
end
176173

177-
def scheduled_at=(value)
178-
@_scheduled_at_time = if value.is_a?(Numeric)
179-
ActiveJob.deprecator.warn(<<~MSG.squish)
180-
Assigning a numeric/epoch value to scheduled_at is deprecated. Use a Time object instead.
181-
MSG
182-
Time.at(value)
183-
else
184-
value
185-
end
186-
@scheduled_at = value
187-
end
188-
189174
private
190175
def serialize_arguments_if_needed(arguments)
191176
if arguments_serialized?

activejob/lib/active_job/enqueuing.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def perform_all_later(*jobs)
2323
adapter_jobs.each do |job|
2424
job.successfully_enqueued = false
2525
if job.scheduled_at
26-
queue_adapter.enqueue_at(job, job._scheduled_at_time.to_f)
26+
queue_adapter.enqueue_at(job, job.scheduled_at.to_f)
2727
else
2828
queue_adapter.enqueue(job)
2929
end
@@ -92,7 +92,7 @@ def enqueue(options = {})
9292

9393
run_callbacks :enqueue do
9494
if scheduled_at
95-
queue_adapter.enqueue_at self, _scheduled_at_time.to_f
95+
queue_adapter.enqueue_at self, scheduled_at.to_f
9696
else
9797
queue_adapter.enqueue self
9898
end

activejob/test/cases/job_serialization_test.rb

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -92,23 +92,4 @@ class JobSerializationTest < ActiveSupport::TestCase
9292

9393
assert_equal job.serialize, deserialized_job.serialize
9494
end
95-
96-
test "deprecates and coerces numerical scheduled_at attribute to Time when serialized and deserialized" do
97-
freeze_time
98-
current_time = Time.now
99-
100-
job = HelloJob.new
101-
assert_deprecated(ActiveJob.deprecator) do
102-
job.scheduled_at = current_time.to_f
103-
end
104-
105-
serialized_job = job.serialize
106-
assert_kind_of String, serialized_job["scheduled_at"]
107-
assert_equal current_time.utc.iso8601(9), serialized_job["scheduled_at"]
108-
109-
deserialized_job = HelloJob.new
110-
deserialized_job.deserialize(serialized_job)
111-
assert_equal current_time, deserialized_job.scheduled_at
112-
assert_equal job.serialize, deserialized_job.serialize
113-
end
11495
end

guides/source/7_2_release_notes.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ Please refer to the [Changelog][active-job] for detailed changes.
147147

148148
* Remove deprecated primitive serializer for `BigDecimal` arguments.
149149

150+
* Remove deprecated support to set numeric values to `scheduled_at` attribute.
151+
150152
### Deprecations
151153

152154
* Deprecate `Rails.application.config.active_job.use_big_decimal_serialize`.

0 commit comments

Comments
 (0)