|
342 | 342 |
|
343 | 343 | it "won't be rescheduled when the time falls back if the job was previously executed" do |
344 | 344 | travel_to Time.parse("2016-11-06 01:00:00 CST") do |
345 | | - expect(task).to receive(:existing_run_times).at_least(:once).and_return([ |
346 | | - Time.parse("2016-11-07 01:30:00 CST") |
| 345 | + tomorrows_run_time = Time.parse("2016-11-07 01:30:00 CST") |
| 346 | + expect(task).to receive(:existing_jobs).and_return([ |
| 347 | + Sidekiq::SortedEntry.new(nil, tomorrows_run_time.to_i, "wrapped" => "TestJob", "class" => "ActiveJob::QueueAdapters::SidekiqAdapter::JobWrapper") |
347 | 348 | ]) |
348 | 349 | expect(task.future_run_times).to eq([ |
| 350 | + Time.parse("2016-11-07 01:30:00 CST"), |
349 | 351 | Time.parse("2016-11-08 01:30:00 CST") |
350 | 352 | ]) |
351 | 353 | end |
|
438 | 440 | end |
439 | 441 | end |
440 | 442 | end |
441 | | - |
442 | | - context "when there are existing run times" do |
443 | | - let(:task) do |
444 | | - described_class.new( |
445 | | - class: "TestJob", |
446 | | - every: "15.minutes", |
447 | | - at: "*:00", |
448 | | - queue_ahead: 60, # minutes |
449 | | - tz: "America/Chicago" |
450 | | - ) |
451 | | - end |
452 | | - |
453 | | - it "only returns the run times that need to be added to the queue" do |
454 | | - travel_to Time.parse("2016-12-01 20:00:00 CST") do |
455 | | - expect(task).to receive(:existing_run_times).at_least(:once).and_return([ |
456 | | - Time.parse("2016-12-01 20:00:00 CST"), |
457 | | - Time.parse("2016-12-01 20:15:00 CST"), |
458 | | - Time.parse("2016-12-01 20:30:00 CST") |
459 | | - ]) |
460 | | - expect(task.future_run_times).to eq([ |
461 | | - Time.parse("2016-12-01 20:45:00 CST"), |
462 | | - Time.parse("2016-12-01 21:00:00 CST") |
463 | | - ]) |
464 | | - end |
465 | | - end |
466 | | - end |
467 | | - |
468 | | - context "when an existing run time is deleted" do |
469 | | - let(:task) do |
470 | | - described_class.new( |
471 | | - class: "TestJob", |
472 | | - every: "15.minutes", |
473 | | - at: "*:00", |
474 | | - queue_ahead: 60, # minutes |
475 | | - tz: "America/Chicago" |
476 | | - ) |
477 | | - end |
478 | | - |
479 | | - it "includes in the missing run time" do |
480 | | - travel_to Time.parse("2016-12-01 20:00:00 CST") do |
481 | | - expect(task).to receive(:existing_run_times).at_least(:once).and_return([ |
482 | | - Time.parse("2016-12-01 20:00:00 CST"), |
483 | | - # Time.parse("2016-12-01 20:15:00 CST"), <-- The missing run time |
484 | | - Time.parse("2016-12-01 20:30:00 CST") |
485 | | - ]) |
486 | | - expect(task.future_run_times).to eq([ |
487 | | - Time.parse("2016-12-01 20:15:00 CST"), # <-- The missing run time |
488 | | - Time.parse("2016-12-01 20:45:00 CST"), |
489 | | - Time.parse("2016-12-01 21:00:00 CST") |
490 | | - ]) |
491 | | - end |
492 | | - end |
493 | | - end |
494 | 443 | end |
495 | 444 | end |
0 commit comments