do not show invoices for free subscription (#2249)

* do not show invoices for free subscription

* use refute instead of negative assert

* changed to refute in the other test too
pull/2261/head
RobertJoonas 4 years ago committed by GitHub
parent 3f7c1ce549
commit 80e01fedd5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -92,8 +92,9 @@ defmodule Plausible.Billing.PaddleApi do
@spec get_invoices(Plausible.Billing.Subscription.t()) ::
{:ok, list()}
| {:error, :request_failed}
| {:error, :no_subscription}
def get_invoices(nil), do: {:error, :no_subscription}
| {:error, :no_invoices}
def get_invoices(nil), do: {:error, :no_invoices}
def get_invoices(%{paddle_subscription_id: nil}), do: {:error, :no_invoices}
def get_invoices(subscription) do
config = get_config()

@ -125,7 +125,7 @@
</div>
<%= case @invoices do %>
<% {:error, :no_subscription} -> %>
<% {:error, :no_invoices} -> %>
<% {:error, :request_failed} -> %>
<div class="max-w-2xl px-8 pt-6 pb-8 mx-auto mt-16 bg-white border-t-2 border-orange-200 rounded rounded-t-none shadow-md dark:bg-gray-800">

@ -557,7 +557,15 @@ defmodule PlausibleWeb.AuthControllerTest do
test "does not show invoice section for a user with no subscription", %{conn: conn} do
conn = get(conn, "/settings")
assert !(html_response(conn, 200) =~ "Invoices")
refute html_response(conn, 200) =~ "Invoices"
end
test "does not show invoice section for a free subscription", %{conn: conn, user: user} do
Plausible.Billing.Subscription.free(%{user_id: user.id, currency_code: "EUR"})
|> Repo.insert!()
conn = get(conn, "/settings")
refute html_response(conn, 200) =~ "Invoices"
end
end

@ -26,7 +26,8 @@ defmodule Plausible.PaddleApi.Mock do
}}
end
def get_invoices(nil), do: {:error, :no_subscription}
def get_invoices(nil), do: {:error, :no_invoices}
def get_invoices(%{paddle_subscription_id: nil}), do: {:error, :no_invoices}
def get_invoices(subscription) do
case subscription.paddle_subscription_id do

Loading…
Cancel
Save