Skip to content

Commit

Permalink
Fix team sync on ownership transfer removal (#4813)
Browse files Browse the repository at this point in the history
  • Loading branch information
zoldar authored Nov 12, 2024
1 parent 7cf61c9 commit c932a25
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/plausible/teams/invitations.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 26 additions & 0 deletions test/plausible_web/controllers/invitation_controller_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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: "[email protected]",
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)])

Expand Down

0 comments on commit c932a25

Please sign in to comment.