|
18 | 18 |
|
19 | 19 | return unless adapter_is?(:test)
|
20 | 20 |
|
| 21 | +class ContinuableJob < ActiveJob::Base |
| 22 | + include ActiveJob::Continuable |
| 23 | +end |
| 24 | + |
21 | 25 | class ActiveJob::TestContinuation < ActiveSupport::TestCase
|
22 | 26 | include ActiveJob::Continuation::TestHelper
|
23 | 27 | include ActiveSupport::Testing::Stream
|
@@ -251,6 +255,38 @@ class ActiveJob::TestContinuation < ActiveSupport::TestCase
|
251 | 255 | assert_equal "Step 'unexpected' found, expected to resume from 'iterating'", exception.message
|
252 | 256 | end
|
253 | 257 |
|
| 258 | + class ContinuableAdvancingJob < ContinuableJob |
| 259 | + def perform(start_from, advance_from = nil) |
| 260 | + step :test_step, start: start_from do |step| |
| 261 | + step.advance! from: advance_from |
| 262 | + end |
| 263 | + end |
| 264 | + end |
| 265 | + |
| 266 | + test "cursor must implement succ to advance" do |
| 267 | + perform_enqueued_jobs do |
| 268 | + assert_raises ActiveJob::Continuation::UnadvanceableCursorError do |
| 269 | + ContinuableAdvancingJob.perform_later(nil) |
| 270 | + end |
| 271 | + |
| 272 | + assert_raises ActiveJob::Continuation::UnadvanceableCursorError do |
| 273 | + ContinuableAdvancingJob.perform_later(1.1) |
| 274 | + end |
| 275 | + |
| 276 | + assert_raises ActiveJob::Continuation::UnadvanceableCursorError do |
| 277 | + ContinuableAdvancingJob.perform_later(nil, 1.1) |
| 278 | + end |
| 279 | + |
| 280 | + assert_nothing_raised do |
| 281 | + ContinuableAdvancingJob.perform_later(1) |
| 282 | + end |
| 283 | + |
| 284 | + assert_nothing_raised do |
| 285 | + ContinuableAdvancingJob.perform_later(nil, 1) |
| 286 | + end |
| 287 | + end |
| 288 | + end |
| 289 | + |
254 | 290 | test "deserializes a job with no continuation" do
|
255 | 291 | ContinuableDeletingJob.items = 10.times.map { |i| "item_#{i}" }
|
256 | 292 | ContinuableDeletingJob.perform_later
|
|
0 commit comments