Accrue.Emails.Fixtures (accrue v0.3.1)

Copy Markdown View Source

Canned assigns for every Accrue.Emails.* type (D6-08).

Lives in lib/ (not test/support/) so that:

  • mix accrue.mail.preview (Plan 06-07) can import without test-env dependencies.
  • ExUnit tests can call it without setup boilerplate.
  • (Phase 7) AccrueAdmin.EmailPreviewLive can import via import Accrue.Emails.Fixtures.

Pure data — zero side effects, no Accrue.Repo calls, no DateTime.utc_now/0. Deterministic: every call returns byte-identical output given no environment changes.

Usage

iex> Accrue.Emails.Fixtures.receipt()
%{context: %{...}, subject: "Receipt", preview: "Thanks for your payment"}

iex> Accrue.Emails.Fixtures.all()
%{receipt: %{...}, payment_failed: %{...}, ...}

Summary

Functions

Returns the full catalogue as a map of email type atom → fixture map.

Base render context re-used by most email fixtures. Contains a frozen branding snapshot, a fake customer, a fake invoice, two line items, and pre-formatted money strings so templates can render without calling Accrue.Invoices.Render.format_money/3.

Fixture for Accrue.Emails.InvoicePaid (MAIL-08).

Fixture for Accrue.Emails.Receipt (MAIL-03).

Fixture for Accrue.Emails.TrialEnded (MAIL-06).

Fixture for Accrue.Emails.TrialEnding (MAIL-05).

Functions

all()

@spec all() :: %{required(atom()) => map()}

Returns the full catalogue as a map of email type atom → fixture map.

Used by mix accrue.mail.preview (Plan 06-07) to iterate every registered type and by ExUnit tests to drive coverage loops.

base_context()

@spec base_context() :: map()

Base render context re-used by most email fixtures. Contains a frozen branding snapshot, a fake customer, a fake invoice, two line items, and pre-formatted money strings so templates can render without calling Accrue.Invoices.Render.format_money/3.

card_expiring_soon()

Fixture for Accrue.Emails.CardExpiringSoon (Phase 3 cron).

coupon_applied()

Fixture for Accrue.Emails.CouponApplied (MAIL-13).

invoice_finalized()

Fixture for Accrue.Emails.InvoiceFinalized (MAIL-07).

invoice_paid()

Fixture for Accrue.Emails.InvoicePaid (MAIL-08).

invoice_payment_failed()

Fixture for Accrue.Emails.InvoicePaymentFailed (MAIL-09).

payment_failed()

Fixture for Accrue.Emails.PaymentFailed (MAIL-04).

receipt()

Fixture for Accrue.Emails.Receipt (MAIL-03).

refund_issued()

Fixture for Accrue.Emails.RefundIssued (MAIL-12).

subscription_canceled()

Fixture for Accrue.Emails.SubscriptionCanceled (MAIL-10).

subscription_paused()

Fixture for Accrue.Emails.SubscriptionPaused (MAIL-11a).

subscription_resumed()

Fixture for Accrue.Emails.SubscriptionResumed (MAIL-11b).

trial_ended()

Fixture for Accrue.Emails.TrialEnded (MAIL-06).

trial_ending()

Fixture for Accrue.Emails.TrialEnding (MAIL-05).