mirror of
https://github.com/plausible/analytics.git
synced 2024-12-25 02:24:55 +03:00
Stop expecting trial_expiry_date
to exist on upgrade (#3688)
* stop expecting trial_expiry_date to exist on upgrade * add test
This commit is contained in:
parent
d3094ffdb7
commit
0a29679afa
@ -208,13 +208,14 @@ defmodule PlausibleWeb.Components.Billing.PlanBox do
|
|||||||
end
|
end
|
||||||
|
|
||||||
defp usage_within_plan_limits?(%{usage: usage, user: user, plan_to_render: plan}) do
|
defp usage_within_plan_limits?(%{usage: usage, user: user, plan_to_render: plan}) do
|
||||||
# At this point, the user is guaranteed to have a `trial_expiry_date`.
|
# At this point, the user is *not guaranteed* to have a `trial_expiry_date`,
|
||||||
# Otherwise, they'd be ineligible for an upgrade and this function
|
# because in the past we've let users upgrade without that constraint, as
|
||||||
# would never be called.
|
# well as transfer sites to those accounts. to these accounts we won't be
|
||||||
%Date{} = user.trial_expiry_date
|
# offering an extra pageview limit allowance margin though.
|
||||||
|
invited_user? = is_nil(user.trial_expiry_date)
|
||||||
|
|
||||||
trial_active_or_ended_recently? =
|
trial_active_or_ended_recently? =
|
||||||
Timex.diff(Timex.today(), user.trial_expiry_date, :days) <= 10
|
not invited_user? && Timex.diff(Timex.today(), user.trial_expiry_date, :days) <= 10
|
||||||
|
|
||||||
limit_checking_opts =
|
limit_checking_opts =
|
||||||
cond do
|
cond do
|
||||||
|
@ -754,6 +754,21 @@ defmodule PlausibleWeb.Live.ChoosePlanTest do
|
|||||||
refute enterprise_box =~ "10+ team members"
|
refute enterprise_box =~ "10+ team members"
|
||||||
refute enterprise_box =~ "Unlimited team members"
|
refute enterprise_box =~ "Unlimited team members"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "allows to upgrade without a trial_expiry_date when the user owns a site", %{
|
||||||
|
conn: conn,
|
||||||
|
user: user
|
||||||
|
} do
|
||||||
|
user
|
||||||
|
|> Plausible.Auth.User.changeset(%{trial_expiry_date: nil})
|
||||||
|
|> Repo.update!()
|
||||||
|
|
||||||
|
{:ok, lv, _doc} = get_liveview(conn)
|
||||||
|
doc = set_slider(lv, "100k")
|
||||||
|
|
||||||
|
refute class_of_element(doc, @growth_checkout_button) =~ "pointer-events-none"
|
||||||
|
refute class_of_element(doc, @business_checkout_button) =~ "pointer-events-none"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "for a free_10k subscription" do
|
describe "for a free_10k subscription" do
|
||||||
|
Loading…
Reference in New Issue
Block a user