Fix disabled invitation form on business tier (#3508)

ref https://github.com/plausible/analytics/pull/3493
This commit is contained in:
hq1 2023-11-10 09:07:30 +01:00 committed by GitHub
parent 2d2ea1a2a3
commit af87a63cab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 4 deletions

View File

@ -30,7 +30,7 @@ defmodule PlausibleWeb.Site.MembershipController do
|> Plausible.Repo.preload(:owner)
limit = Plausible.Billing.Quota.team_member_limit(site.owner)
usage = Plausible.Billing.Quota.team_member_limit(site.owner)
usage = Plausible.Billing.Quota.team_member_usage(site.owner)
below_limit? = Plausible.Billing.Quota.below_limit?(usage, limit)
render(

View File

@ -3,15 +3,36 @@ defmodule PlausibleWeb.Site.MembershipControllerTest do
use Plausible.Repo
use Bamboo.Test
import Plausible.Test.Support.HTML
setup [:create_user, :log_in]
describe "GET /sites/:website/memberships/invite" do
test "shows invite form", %{conn: conn, user: user} do
site = insert(:site, members: [user])
conn = get(conn, "/sites/#{site.domain}/memberships/invite")
html =
conn
|> get("/sites/#{site.domain}/memberships/invite")
|> html_response(200)
assert html_response(conn, 200) =~ "Invite member to"
assert html =~ "Invite member to"
assert element_exists?(html, ~s/button[type=submit]/)
refute element_exists?(html, ~s/button[type=submit][disabled]/)
end
test "disables invite form when is over limit", %{conn: conn, user: user} do
memberships =
[build(:site_membership, user: user, role: :owner) | build_list(5, :site_membership)]
site = insert(:site, memberships: memberships)
html =
conn
|> get("/sites/#{site.domain}/memberships/invite")
|> html_response(200)
assert element_exists?(html, ~s/button[type=submit][disabled]/)
end
end
@ -33,7 +54,7 @@ defmodule PlausibleWeb.Site.MembershipControllerTest do
test "fails to create invitation when is over limit", %{conn: conn, user: user} do
memberships =
[build(:site_membership, user: user, role: :owner)] ++ build_list(5, :site_membership)
[build(:site_membership, user: user, role: :owner) | build_list(5, :site_membership)]
site = insert(:site, memberships: memberships)