Fix team sync on ownership transfer removal (#4813)

This commit is contained in:
Adrian Gruntkowski 2024-11-12 16:08:42 +01:00 committed by GitHub
parent 7cf61c9590
commit c932a25fd6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 27 additions and 1 deletions

View File

@ -78,7 +78,7 @@ defmodule Plausible.Teams.Invitations do
from(
st in Teams.SiteTransfer,
where: st.email == ^site_invitation.email,
where: st.team_id == ^site.team.id
where: st.site_id == ^site.id
)
)
else

View File

@ -229,6 +229,32 @@ defmodule PlausibleWeb.Site.InvitationControllerTest do
refute Repo.reload(invitation)
end
test "removes the invitation for ownership transfer", %{conn: conn, user: user} do
site =
insert(:site,
members: [build(:user)],
memberships: [build(:site_membership, user: user, role: :admin)]
)
invitation =
insert(:invitation,
site_id: site.id,
inviter: build(:user),
email: "jane@example.com",
role: :owner
)
conn =
delete(
conn,
Routes.invitation_path(conn, :remove_invitation, site.domain, invitation.invitation_id)
)
assert redirected_to(conn, 302) == "/#{URI.encode_www_form(site.domain)}/settings/people"
refute Repo.reload(invitation)
end
test "fails to remove an invitation with insufficient permission", %{conn: conn, user: user} do
site = insert(:site, memberships: [build(:site_membership, user: user, role: :viewer)])