add newsletter and email campaigns
Subscribers with double opt-in confirmation, campaign composer with draft/scheduled/sent lifecycle, admin dashboard with overview stats, CSV export, and shop signup form wired into page builder blocks. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
40
test/support/fixtures/newsletter_fixtures.ex
Normal file
40
test/support/fixtures/newsletter_fixtures.ex
Normal file
@@ -0,0 +1,40 @@
|
||||
defmodule Berrypod.NewsletterFixtures do
|
||||
@moduledoc """
|
||||
Test helpers for creating newsletter subscribers and campaigns.
|
||||
"""
|
||||
|
||||
alias Berrypod.Newsletter
|
||||
|
||||
def unique_email, do: "user#{System.unique_integer([:positive])}@example.com"
|
||||
|
||||
@doc """
|
||||
Creates a confirmed subscriber directly via Repo, bypassing the
|
||||
confirmation email flow.
|
||||
"""
|
||||
def confirmed_subscriber_fixture(attrs \\ %{}) do
|
||||
now = DateTime.utc_now() |> DateTime.truncate(:second)
|
||||
|
||||
attrs =
|
||||
Enum.into(attrs, %{
|
||||
email: unique_email(),
|
||||
status: "confirmed",
|
||||
confirmed_at: now,
|
||||
consent_text: "Test signup"
|
||||
})
|
||||
|
||||
%Newsletter.Subscriber{}
|
||||
|> Newsletter.Subscriber.changeset(attrs)
|
||||
|> Berrypod.Repo.insert!()
|
||||
end
|
||||
|
||||
def campaign_fixture(attrs \\ %{}) do
|
||||
attrs =
|
||||
Enum.into(attrs, %{
|
||||
subject: "Test campaign #{System.unique_integer([:positive])}",
|
||||
body: "Hello! Unsubscribe: {{unsubscribe_url}}"
|
||||
})
|
||||
|
||||
{:ok, campaign} = Newsletter.create_campaign(attrs)
|
||||
campaign
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user