corretti bug sull'invio email
CI / scan_ruby (push) Failing after 12m46s
CI / scan_js (push) Successful in 12m35s
CI / lint (push) Failing after 12m46s

This commit is contained in:
2026-09-10 17:08:50 +02:00
parent 36b3ffe507
commit 3f7794959e
8 changed files with 59 additions and 6 deletions
@@ -85,6 +85,33 @@ class Mailings::OutboundQueueTest < ActiveSupport::TestCase
assert_equal "queued", recipient_a.status
assert_match(/Da ritentare \(1\/8\)/, recipient_a.error_message)
assert_equal recipient_b.id, Mailings::OutboundQueue.next_queued.id
# Il contatore deve avanzare sullo stesso destinatario (prima il regex
# non matchava "Da ritentare (N/8)" e restava sempre tentativo 1).
begin
gate.define_singleton_method(:deliver) { raise EOFError, "end of file reached" }
assert_equal :deferred, recipient_a.deliver_queued!
ensure
gate.define_singleton_method(:deliver, original)
end
assert_match(/Da ritentare \(2\/8\)/, recipient_a.reload.error_message)
end
test "next_queued skips recipients whose send window is closed" do
open_org = create_campaign_org(name: "Club Aperto", email: "aperto@example.com")
closed_org = create_campaign_org(name: "Club Chiuso", email: "chiuso@example.com")
open_mailing = create_sending_mailing(name: "Finestra aperta")
closed_mailing = create_sending_mailing(name: "Finestra chiusa")
closed_mailing.update!(send_window_enabled: true, send_window_start_minutes: 8 * 60, send_window_end_minutes: 9 * 60)
open_mailing.update!(send_window_enabled: false)
closed_recipient = enqueue_org(closed_mailing, closed_org)
open_recipient = enqueue_org(open_mailing, open_org)
closed_recipient.update_columns(updated_at: 1.hour.ago)
travel_to Time.zone.local(2026, 9, 10, 20, 0, 0) do
assert_equal open_recipient.id, Mailings::OutboundQueue.next_queued.id
end
end
private