Files
openfoodnetwork/spec/jobs/order_cycle_notification_job_spec.rb
Maikel Linke 8daa01e228 Process OC emails individually to avoid duplicates
Errors or delays can cause multiple duplicate emails to the same
suppliers.
2025-05-02 16:58:00 +10:00

22 lines
558 B
Ruby

# frozen_string_literal: true
require 'spec_helper'
RSpec.describe OrderCycleNotificationJob do
let(:order_cycle) { create(:order_cycle) }
it "sends a mail to each supplier" do
expect {
OrderCycleNotificationJob.perform_now(order_cycle.id)
}.to enqueue_mail(ProducerMailer, :order_cycle_report).twice
end
it "records that mails have been sent for the order cycle" do
expect {
OrderCycleNotificationJob.perform_now(order_cycle.id)
}.to change {
order_cycle.reload.mails_sent?
}.from(false).to(true)
end
end