Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.
TypeScript analyticsanalytics-dashboardclickhouseelixirgoogle-analyticsmarketingopen-source-analyticsphoenixplausible-analyticspostgresqlprivacyprivacy-friendlyself-hostedsimple-analyticsstatisticstailwindcssweb-analyticswebsite-analyticswebsite-statswebsite-tracking
Fix tests
Uku Taht1d4ae3d16f44
diff --git a/lib/workers/check_usage.ex b/lib/workers/check_usage.exindex 37206b46a0..ea021c95d9 100644--- a/lib/workers/check_usage.ex+++ b/lib/workers/check_usage.ex@@ -30,8 +30,8 @@ defmodule Plausible.Workers.CheckUsage doend@impl Oban.Worker- def perform(_args, _job, billing_mod \\ Plausible.Billing) do- yesterday = Timex.today() |> Timex.shift(days: -1)+ def perform(_args, _job, billing_mod \\ Plausible.Billing, today \\ Timex.today()) do+ yesterday = today |> Timex.shift(days: -1)active_subscribers =Repo.all(diff --git a/test/workers/check_usage_test.exs b/test/workers/check_usage_test.exsindex 862272d421..87aa8584d5 100644--- a/test/workers/check_usage_test.exs+++ b/test/workers/check_usage_test.exs@@ -118,7 +118,7 @@ defmodule Plausible.Workers.CheckUsageTest do)end- test "for yearly subscriptions, does not check exactly one month after last_bill_date", %{+ test "does not check exactly one month after last_bill_date", %{user: user} dobilling_stub =@@ -131,38 +131,14 @@ defmodule Plausible.Workers.CheckUsageTest doinsert(:subscription,user: user,paddle_plan_id: @paddle_id_10k,- last_bill_date: Timex.shift(Timex.today(), months: -1)+ last_bill_date: ~D[2021-03-28])- CheckUsage.perform(nil, nil, billing_stub)+ CheckUsage.perform(nil, nil, billing_stub, ~D[2021-03-28])assert_no_emails_delivered()end- test "for yearly subscriptions, checks usage one month + one day after the last_bill_date", %{- 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(), months: -1, days: -1)- )-- CheckUsage.perform(nil, nil, billing_stub)-- assert_email_delivered_with(- to: [user],- subject: "You have outgrown your Plausible subscription tier "- )- end-test "for yearly subscriptions, checks usage multiple months + one day after the last_bill_date",%{user: user