Carica oggetto e corpo dell'email appena si sceglie un template A/B.
CI / scan_ruby (push) Failing after 10m36s
CI / scan_js (push) Successful in 10m31s
CI / lint (push) Failing after 11m0s

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-17 23:24:39 +02:00
co-authored by Cursor
parent c4e5f289cf
commit 4ddf534a0c
5 changed files with 150 additions and 29 deletions
@@ -104,4 +104,53 @@ class MailingsControllerTest < ActionDispatch::IntegrationTest
body = (mail.html_part || mail).body.to_s
assert_match(/Versione B/, body)
end
test "new mailing form embeds template content for the picker" do
login_as users(:admin)
follow_redirect! if response.redirect?
template = MailTemplate.create!(
project: @project,
name: "Variante B picker",
subject: "Oggetto dal template B",
body_html: "<p>Corpo dal template B</p>"
)
get new_mailing_path(project_code: @project.code)
assert_response :success
assert_match(/template-picker/, response.body)
assert_match(/Oggetto dal template B/, response.body)
assert_match(/Corpo dal template B/, response.body)
assert_includes response.body, template.id.to_s
end
test "create copies blank variant B fields from selected template" do
login_as users(:admin)
follow_redirect! if response.redirect?
template_b = MailTemplate.create!(
project: @project,
name: "Template B server",
subject: "B {{societa}}",
body_html: "<p>Versione B dal template</p>"
)
post mailings_path(project_code: @project.code), params: {
mailing: {
name: "AB da template",
mail_identity_id: @identity.id,
mail_template_b_id: template_b.id,
audience: "to_send",
ab_test: "1",
ab_assignment: "from_record",
subject: "Oggetto A",
body_html: "<p>Versione A</p>",
subject_b: "",
body_html_b: "",
interval_seconds: 0
}
}
mailing = Mailing.last
assert_redirected_to mailing_path(mailing, project_code: @project.code)
assert_equal "B {{societa}}", mailing.subject_b
assert_includes mailing.body_html_b, "Versione B dal template"
end
end