Rename OrderCycleOpenedJob

This name better reflects what it's doing.

As this job is scheduled automatically by Sidekiq, I think there shouldn't be any jobs with the old name in redis. So I didn't bother keeping a placholder for the old name.

And Clean up unused include
This commit is contained in:
David Cook
2025-02-26 16:05:28 +11:00
committed by Maikel Linke
parent 6738101ebd
commit ff7c23c8f9
3 changed files with 4 additions and 7 deletions

View File

@@ -1,7 +1,7 @@
# frozen_string_literal: true
# Trigger jobs for any order cycles that recently opened
class OrderCycleOpenedJob < ApplicationJob
class TriggerOrderCyclesToOpenJob < ApplicationJob
def perform
recently_opened_order_cycles.find_each do |order_cycle|
OpenOrderCycleJob.perform_later(order_cycle.id)

View File

@@ -15,7 +15,7 @@
every: "5m"
SubscriptionConfirmJob:
every: "5m"
OrderCycleOpenedJob:
TriggerOrderCyclesToOpenJob:
every: "5m"
OrderCycleClosingJob:
every: "5m"

View File

@@ -1,11 +1,8 @@
# frozen_string_literal: true
require 'spec_helper'
require_relative '../../engines/dfc_provider/spec/support/authorization_helper'
RSpec.describe OrderCycleOpenedJob do
include AuthorizationHelper
RSpec.describe TriggerOrderCyclesToOpenJob do
let(:oc_opened_before) {
create(:simple_order_cycle, orders_open_at: 1.hour.ago)
}
@@ -17,7 +14,7 @@ RSpec.describe OrderCycleOpenedJob do
}
it "enqueues jobs for recently opened order cycles only" do
expect{ OrderCycleOpenedJob.perform_now }
expect{ TriggerOrderCyclesToOpenJob.perform_now }
.to enqueue_job(OpenOrderCycleJob).with(oc_opened_now.id)
.and enqueue_job(OpenOrderCycleJob).with(oc_opened_before.id).exactly(0).times
.and enqueue_job(OpenOrderCycleJob).with(oc_opening_soon.id).exactly(0).times