forked from plausible/analytics
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Only check usage for EPs by _current_ subscription (plausible#4929)
- Loading branch information
Showing
2 changed files
with
34 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -372,6 +372,38 @@ defmodule Plausible.Workers.CheckUsageTest do | |
) | ||
end | ||
|
||
test "will only check usage if enterprise plan matches subscription's paddle plan id", | ||
%{ | ||
user: user | ||
} do | ||
usage_stub = | ||
Plausible.Teams.Billing | ||
|> stub(:monthly_pageview_usage, fn _user -> | ||
%{ | ||
penultimate_cycle: %{date_range: @date_range, total: 1_100_000}, | ||
last_cycle: %{date_range: @date_range, total: 1_100_000} | ||
} | ||
end) | ||
|
||
subscribe_to_enterprise_plan( | ||
user, | ||
monthly_pageview_limit: 1_000_000, | ||
subscription: [ | ||
last_bill_date: Timex.shift(Timex.today(), days: -1), | ||
status: unquote(status), | ||
# non-matching ID | ||
paddle_plan_id: @paddle_id_10k | ||
] | ||
) | ||
|
||
CheckUsage.perform(nil, usage_stub) | ||
|
||
refute_email_delivered_with( | ||
to: [{nil, "[email protected]"}], | ||
subject: "#{user.email} has outgrown their enterprise plan" | ||
) | ||
end | ||
|
||
test "checks site limit for enterprise customer, sends usage information to [email protected]", | ||
%{ | ||
user: user | ||
|