|
|
|
|
@ -97,6 +97,32 @@ defmodule Plausible.Workers.CheckUsageTest do
|
|
|
|
|
assert Repo.reload(user).grace_period.end_date == Timex.shift(Timex.today(), days: 7)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
test "reccommends a plan to upgrade to", %{
|
|
|
|
|
user: user
|
|
|
|
|
} do
|
|
|
|
|
billing_stub =
|
|
|
|
|
Plausible.Billing
|
|
|
|
|
|> stub(:last_two_billing_months_usage, fn _user -> {11_000, 11_000} end)
|
|
|
|
|
|> stub(:last_two_billing_cycles, fn _user ->
|
|
|
|
|
{Date.range(Timex.today(), Timex.today()), Date.range(Timex.today(), Timex.today())}
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
insert(:subscription,
|
|
|
|
|
user: user,
|
|
|
|
|
paddle_plan_id: @paddle_id_10k,
|
|
|
|
|
last_bill_date: Timex.shift(Timex.today(), days: -1)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
CheckUsage.perform(nil, billing_stub)
|
|
|
|
|
|
|
|
|
|
assert_delivered_email_matches(%{
|
|
|
|
|
html_body: html_body
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
# Should find 2 visiors
|
|
|
|
|
assert html_body =~ ~s(Based on that we recommend you select the 100k/mo plan.)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
describe "enterprise customers" do
|
|
|
|
|
test "checks billable pageview usage for enterprise customer, sends usage information to enterprise@plausible.io",
|
|
|
|
|
%{
|
|
|
|
|
|