Small, provider-free entitlement fixtures for host application tests.
These helpers insert only Accrue's normalized Account and Grant rows;
they never call Stripe or Apple and never require provider credentials.
The four common rendering states are available through insert!/2:
:none:stripe_active:stripe_cancelled_but_entitled:apple_active
Configure matching products in the host test environment:
config :accrue,
processor: Accrue.Processor.Fake,
rails: [
stripe: [
source: :stripe,
processor: Accrue.Processor.Fake,
environments: [:production],
default_environment: :production
],
apple: [
source: :apple,
environments: [:production],
default_environment: :production
]
],
default_rail: :stripe,
entitlements: [
plans: [
pro: [
features: [:pro],
limits: [seats: 1],
products: [
stripe: [production: ["price_test_pro"]],
apple: [production: ["com.example.test.pro"]]
]
]
]
]:stripe_cancelled_but_entitled models cancellation at period end: the
grant remains current and gets a future expires_at. Override that boundary
with :expires_at when a test needs an exact timestamp.
Summary
Types
@type fixture() :: %{ account: Accrue.Entitlements.Account.t(), grants: [Accrue.Entitlements.Grant.t()] }
@type scenario() ::
:none | :stripe_active | :stripe_cancelled_but_entitled | :apple_active
Functions
Inserts one of the standard entitlement states through the configured Repo.
Options include :owner_type, :owner_id, :plan, :quantity, :now,
:expires_at, and rail-specific :stripe_product_id / :apple_product_id.
@spec insert!(Ecto.Repo.t(), scenario(), keyword()) :: fixture()
Same as insert!/2, using an explicit Ecto Repo.