Files
eminuxandCursor 1f946f63ba
CI / scan_ruby (push) Failing after 18m40s
CI / scan_js (push) Successful in 11m46s
CI / lint (push) Failing after 13m8s
Aggiunge filtri avanzati per i destinatari delle campagne email.
La scelta della lista passa da un wizard a tre passi, con anteprima del conteggio e lista congelata solo dopo la conferma.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-24 21:00:11 +02:00

88 lines
2.2 KiB
Ruby

ENV["RAILS_ENV"] ||= "test"
require_relative "../config/environment"
require "rails/test_help"
module ActiveSupport
class TestCase
parallelize(workers: :number_of_processors)
fixtures :all
end
end
class ActionDispatch::IntegrationTest
def login_as(user, password: "password123")
post login_path, params: { email: user.email, password: password }
end
end
module MailMarketingTestHelper
def create_mail_identity(**attrs)
MailIdentity.create!(
{
name: "SMTP test",
from_name: "eminuxCRM",
from_email: "hello@example.com",
smtp_host: "smtp.example.com",
smtp_port: 587,
smtp_username: "user",
smtp_password: "secret",
smtp_authentication: "plain",
encryption: "starttls",
verify_ssl: true,
active: true
}.merge(attrs)
)
end
def create_mailing(project: projects(:matchlivetv), identity: nil, **attrs)
Mailing.create!(
{
project: project,
mail_identity: identity || create_mail_identity,
name: "Campagna test",
subject: "Ciao {{societa}}",
body_html: "<p>Ciao {{contatto_nome}} di {{societa}}</p>",
audience: "all",
interval_seconds: 0,
ab_test: false,
ab_assignment: "from_record"
}.merge(attrs)
)
end
def create_campaign_org(name:, email:, ab_variant: nil, send_status: "to_send", list_position: nil, **org_attrs)
project = projects(:matchlivetv)
org = Organization.new(
{
name: name,
status: "prospect",
organization_type: "societa_sportiva",
email: email,
list_position: list_position
}.merge(org_attrs)
)
org.organization_projects.build(project: project)
org.save!
Contact.create!(
organization: org,
first_name: "Contatto",
last_name: name,
email: email,
primary_contact: true
)
Opportunity.create!(
organization: org,
project: project,
name: "Campagna",
pipeline_stage: "to_contact",
send_status: send_status,
ab_variant: ab_variant
)
org
end
end
ActiveSupport::TestCase.include MailMarketingTestHelper
ActionDispatch::IntegrationTest.include MailMarketingTestHelper