Commit iniziale di eminuxCRM: CRM Rails con pipeline, campagne email e Docker.
Include autenticazione, progetti isolati, mail marketing HTML con SMTP, test A/B e editor WYSIWYG. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,85 @@
|
||||
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)
|
||||
project = projects(:matchlivetv)
|
||||
org = Organization.new(
|
||||
name: name,
|
||||
status: "prospect",
|
||||
organization_type: "societa_sportiva",
|
||||
email: email,
|
||||
list_position: list_position
|
||||
)
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user