mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Convert OrderCycleNotificationJob to ActiveJob
This commit is contained in:
@@ -91,7 +91,7 @@ module Admin
|
||||
|
||||
# Send notifications to all producers who are part of the order cycle
|
||||
def notify_producers
|
||||
Delayed::Job.enqueue OrderCycleNotificationJob.new(params[:id].to_i)
|
||||
OrderCycleNotificationJob.perform_later params[:id].to_i
|
||||
|
||||
redirect_to main_app.admin_order_cycles_path,
|
||||
notice: I18n.t(:order_cycles_email_to_producers_notice)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Delivers an email with a report of the order cycle to each of its suppliers
|
||||
OrderCycleNotificationJob = Struct.new(:order_cycle_id) do
|
||||
def perform
|
||||
class OrderCycleNotificationJob < ActiveJob::Base
|
||||
def perform(order_cycle_id)
|
||||
order_cycle = OrderCycle.find(order_cycle_id)
|
||||
order_cycle.suppliers.each do |supplier|
|
||||
ProducerMailer.order_cycle_report(supplier, order_cycle).deliver
|
||||
|
||||
@@ -9,7 +9,7 @@ describe OrderCycleNotificationJob do
|
||||
end
|
||||
|
||||
it 'sends a mail to each supplier' do
|
||||
run_job OrderCycleNotificationJob.new(order_cycle.id)
|
||||
OrderCycleNotificationJob.perform_now order_cycle.id
|
||||
expect(ProducerMailer).to have_received(:order_cycle_report).twice
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user