Aggiunge fascia oraria, prova manuale obbligatoria e cruscotto invii email.
CI / lint (push) Failing after 16m2s
CI / scan_ruby (push) Has been cancelled
CI / scan_js (push) Has been cancelled

Le campagne rispettano orario e giorni lavorativi, richiedono una mail di test con dati inseriti a mano prima dell'invio massivo e offrono una dashboard per monitorare l'avanzamento.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-18 00:04:33 +02:00
co-authored by Cursor
parent 4ddf534a0c
commit 98dcdbbf82
33 changed files with 882 additions and 56 deletions
+10
View File
@@ -33,4 +33,14 @@ class MailMergeTest < ActiveSupport::TestCase
test "unknown tokens become empty string" do
assert_equal "X Y", MailMerge.render("X {{sconosciuto}} Y")
end
test "extras override variables for manual test data" do
html = MailMerge.render(
"Ciao {{contatto_nome}} di {{societa}}",
organization: organizations(:acme),
project: projects(:matchlivetv),
extras: { societa: "Override SRL", contatto_nome: "Manual Test" }
)
assert_equal "Ciao Manual Test di Override SRL", html
end
end
+64
View File
@@ -0,0 +1,64 @@
require "test_helper"
class Mailings::SendClockTest < ActiveSupport::TestCase
setup do
@mailing = create_mailing(
send_window_enabled: true,
send_window_start_minutes: 10 * 60,
send_window_end_minutes: 18 * 60,
interval_seconds: 120
)
end
test "is open inside weekday window" do
travel_to Time.zone.local(2026, 4, 1, 11, 0, 0) do
clock = Mailings::SendClock.new(@mailing)
assert clock.open?
assert_equal Time.zone.now, clock.next_send_at
end
end
test "waits until window start the same weekday" do
travel_to Time.zone.local(2026, 4, 1, 8, 30, 0) do
clock = Mailings::SendClock.new(@mailing)
assert_not clock.open?
assert_equal Time.zone.local(2026, 4, 1, 10, 0, 0), clock.next_open_at
end
end
test "after window end skips weekend and Italian holiday to next workday" do
# Venerdì 3 aprile 2026 18:30. Lunedi 6 è Pasquetta → martedì 7 alle 10:00.
travel_to Time.zone.local(2026, 4, 3, 18, 30, 0) do
clock = Mailings::SendClock.new(@mailing)
assert_not clock.open?
assert_equal Time.zone.local(2026, 4, 7, 10, 0, 0), clock.next_open_at
end
end
test "interval that would land after 18:00 moves to next workday" do
travel_to Time.zone.local(2026, 4, 1, 17, 59, 0) do
clock = Mailings::SendClock.new(@mailing)
at = clock.next_send_at(earliest: Time.current + 120.seconds)
assert_equal Time.zone.local(2026, 4, 2, 10, 0, 0), at
end
end
test "disabled window sends anytime including weekend" do
@mailing.update!(send_window_enabled: false)
travel_to Time.zone.local(2026, 4, 4, 21, 0, 0) do
clock = Mailings::SendClock.new(@mailing)
assert clock.open?
assert_equal Time.zone.now, clock.next_send_at
end
end
end
class Italy::HolidaysTest < ActiveSupport::TestCase
test "computes Easter and Italian fixed holidays" do
assert_equal Date.new(2026, 4, 5), Italy::Holidays.easter_date(2026)
assert Italy::Holidays.holiday?(Date.new(2026, 4, 5))
assert Italy::Holidays.holiday?(Date.new(2026, 4, 6))
assert Italy::Holidays.holiday?(Date.new(2026, 8, 15))
assert_not Italy::Holidays.holiday?(Date.new(2026, 4, 7))
end
end