-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WIP] Switch ownership transfer operations to read from team schemas …
…behind FF
- Loading branch information
Showing
6 changed files
with
288 additions
and
324 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,16 +75,15 @@ defmodule Plausible.Site.AdminTest do | |
end | ||
|
||
test "new owner must be an existing user", %{conn: conn, transfer_direct_action: action} do | ||
site = insert(:site) | ||
site = new_site() | ||
|
||
assert action.(conn, [site], %{"email" => "[email protected]"}) == | ||
{:error, "User could not be found"} | ||
end | ||
|
||
test "new owner can't be the same as old owner", %{conn: conn, transfer_direct_action: action} do | ||
current_owner = insert(:user) | ||
|
||
site = insert(:site, members: [current_owner]) | ||
current_owner = new_user() | ||
site = new_site(owner: current_owner) | ||
|
||
assert {:error, "User is already an owner of one of the sites"} = | ||
action.(conn, [site], %{"email" => current_owner.email}) | ||
|
@@ -96,20 +95,16 @@ defmodule Plausible.Site.AdminTest do | |
transfer_direct_action: action | ||
} do | ||
today = Date.utc_today() | ||
current_owner = insert(:user) | ||
current_owner = new_user() | ||
|
||
new_owner = | ||
insert(:user, | ||
subscription: | ||
build(:growth_subscription, | ||
last_bill_date: Timex.shift(today, days: -5) | ||
) | ||
) | ||
new_user() | ||
|> subscribe_to_growth_plan(last_bill_date: Date.shift(today, day: -5)) | ||
|
||
# fills the site limit quota | ||
insert_list(10, :site, members: [new_owner]) | ||
for _ <- 1..10, do: new_site(owner: new_owner) | ||
|
||
site = insert(:site, members: [current_owner]) | ||
site = new_site(owner: current_owner) | ||
|
||
assert {:error, "Plan limits exceeded" <> _} = | ||
action.(conn, [site], %{"email" => new_owner.email}) | ||
|
@@ -120,18 +115,14 @@ defmodule Plausible.Site.AdminTest do | |
transfer_direct_action: action | ||
} do | ||
today = Date.utc_today() | ||
current_owner = insert(:user) | ||
current_owner = new_user() | ||
|
||
new_owner = | ||
insert(:user, | ||
subscription: build(:subscription, last_bill_date: Timex.shift(today, days: -5)) | ||
) | ||
|
||
site1 = | ||
insert(:site, memberships: [build(:site_membership, user: current_owner, role: :owner)]) | ||
new_user() | ||
|> subscribe_to_growth_plan(last_bill_date: Date.shift(today, day: -5)) | ||
|
||
site2 = | ||
insert(:site, memberships: [build(:site_membership, user: current_owner, role: :owner)]) | ||
site1 = new_site(owner: current_owner) | ||
site2 = new_site(owner: current_owner) | ||
|
||
assert :ok = action.(conn, [site1, site2], %{"email" => new_owner.email}) | ||
end | ||
|
Oops, something went wrong.