Skip to content

Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.

Fix tests

Uku Tahtebdd856df7f3
diff --git a/lib/plausible_web/controllers/billing_controller.ex b/lib/plausible_web/controllers/billing_controller.ex
index 012a327e17..9c9cd1e91d 100644
--- a/lib/plausible_web/controllers/billing_controller.ex
+++ b/lib/plausible_web/controllers/billing_controller.ex
@@ -80,21 +80,12 @@ defmodule PlausibleWeb.BillingController do
def change_enterprise_plan(conn, %{"plan_id" => plan_id}) do
user = conn.assigns[:current_user]
- current_plan =
- Repo.get_by(Plausible.Billing.EnterprisePlan,
- user_id: user.id,
- paddle_plan_id: user.subscription.paddle_plan_id
- )
-
new_plan = Repo.get_by(Plausible.Billing.EnterprisePlan, user_id: user.id, id: plan_id)
cond do
is_nil(user.subscription) ->
redirect(conn, to: "/billing/upgrade")
- is_nil(current_plan) ->
- render_error(conn, 404)
-
is_nil(new_plan) || new_plan.paddle_plan_id == user.subscription.paddle_plan_id ->
render_error(conn, 404)
@@ -109,7 +100,6 @@ defmodule PlausibleWeb.BillingController do
def change_plan_preview(conn, %{"plan_id" => new_plan_id}) do
subscription = Billing.active_subscription_for(conn.assigns[:current_user].id)
- IO.inspect(subscription)
if subscription do
{:ok, preview_info} = Billing.change_plan_preview(subscription, new_plan_id)
diff --git a/test/plausible_web/controllers/billing_controller_test.exs b/test/plausible_web/controllers/billing_controller_test.exs
index 43b60effe6..072277dc2d 100644
--- a/test/plausible_web/controllers/billing_controller_test.exs
+++ b/test/plausible_web/controllers/billing_controller_test.exs
@@ -58,13 +58,13 @@ defmodule PlausibleWeb.BillingControllerTest do
assert redirected_to(conn) == "/billing/upgrade"
end
- test "redirects to enterprise change plan page if user has enterprise plan and existing subscription",
+ test "prompts to contact us if user has enterprise plan and existing subscription",
%{conn: conn, user: user} do
insert(:subscription, user: user)
- plan = insert(:enterprise_plan, user: user)
+ insert(:enterprise_plan, user: user)
conn = get(conn, "/billing/change-plan")
- assert redirected_to(conn) == "/billing/change-plan/enterprise/#{plan.id}"
+ assert html_response(conn, 200) =~ "please contact us"
end
end