From ebdd856df7f32496270c4bc6f4f190c19563a8c3 Mon Sep 17 00:00:00 2001 From: Uku Taht Date: Tue, 29 Mar 2022 13:06:44 +0300 Subject: [PATCH] Fix tests --- lib/plausible_web/controllers/billing_controller.ex | 10 ---------- .../controllers/billing_controller_test.exs | 6 +++--- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/lib/plausible_web/controllers/billing_controller.ex b/lib/plausible_web/controllers/billing_controller.ex index 012a327e1..9c9cd1e91 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 43b60effe..072277dc2 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