From 248d43ee47ed2320bc9ff950c421dd3062ee8663 Mon Sep 17 00:00:00 2001 From: Uku Taht Date: Tue, 18 Aug 2020 12:48:01 +0300 Subject: [PATCH] Add page after upgrading to paid plan (#288) --- .../controllers/billing_controller.ex | 6 ++---- lib/plausible_web/router.ex | 2 +- .../templates/billing/upgrade.html.eex | 2 +- .../templates/billing/upgrade_success.html.eex | 18 ++++++++++++++++++ .../controllers/billing_controller_test.exs | 10 ++++++++++ 5 files changed, 32 insertions(+), 6 deletions(-) create mode 100644 lib/plausible_web/templates/billing/upgrade_success.html.eex diff --git a/lib/plausible_web/controllers/billing_controller.ex b/lib/plausible_web/controllers/billing_controller.ex index 685ebb3ed..3496a0059 100644 --- a/lib/plausible_web/controllers/billing_controller.ex +++ b/lib/plausible_web/controllers/billing_controller.ex @@ -76,9 +76,7 @@ defmodule PlausibleWeb.BillingController do ) end - def success(conn, _params) do - conn - |> put_flash(:success, "Subscription created successfully") - |> redirect(to: "/settings") + def upgrade_success(conn, _params) do + render(conn, "upgrade_success.html", layout: {PlausibleWeb.LayoutView, "focus.html"}) end end diff --git a/lib/plausible_web/router.ex b/lib/plausible_web/router.ex index 8f532e552..e3c521252 100644 --- a/lib/plausible_web/router.ex +++ b/lib/plausible_web/router.ex @@ -103,7 +103,7 @@ defmodule PlausibleWeb.Router do get "/billing/change-plan/preview/:plan_id", BillingController, :change_plan_preview post "/billing/change-plan/:new_plan_id", BillingController, :change_plan get "/billing/upgrade", BillingController, :upgrade - get "/billing/success", BillingController, :success + get "/billing/upgrade-success", BillingController, :upgrade_success get "/sites", SiteController, :index get "/sites/new", SiteController, :new diff --git a/lib/plausible_web/templates/billing/upgrade.html.eex b/lib/plausible_web/templates/billing/upgrade.html.eex index 5f8b40cf2..7a77d4679 100644 --- a/lib/plausible_web/templates/billing/upgrade.html.eex +++ b/lib/plausible_web/templates/billing/upgrade.html.eex @@ -102,7 +102,7 @@
Due today: $6
- diff --git a/lib/plausible_web/templates/billing/upgrade_success.html.eex b/lib/plausible_web/templates/billing/upgrade_success.html.eex new file mode 100644 index 000000000..de6233617 --- /dev/null +++ b/lib/plausible_web/templates/billing/upgrade_success.html.eex @@ -0,0 +1,18 @@ +
+
+
+ Subscription created succesfully +
+ +
+ Thank you for upgrading your subscription. You will be redirected to your + account within 5 seconds. +
+ +
+ + +
+
diff --git a/test/plausible_web/controllers/billing_controller_test.exs b/test/plausible_web/controllers/billing_controller_test.exs index 1376187c2..f115f0d9f 100644 --- a/test/plausible_web/controllers/billing_controller_test.exs +++ b/test/plausible_web/controllers/billing_controller_test.exs @@ -33,4 +33,14 @@ defmodule PlausibleWeb.BillingControllerTest do assert subscription.next_bill_amount == "6.00" end end + + describe "GET /billing/upgrade-success" do + setup [:create_user, :log_in] + + test "shows success page after user subscribes", %{conn: conn} do + conn = get(conn, "/billing/upgrade-success") + + assert html_response(conn, 200) =~ "Subscription created succesfully" + end + end end