-
-
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.
Only touch session once an hour and keep
user.last_seen
in sync
- Loading branch information
Showing
6 changed files
with
99 additions
and
58 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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -954,7 +954,7 @@ defmodule PlausibleWeb.SiteControllerTest do | |
|
||
describe "PUT /:website/settings/features/visibility/:setting" do | ||
def query_conn_with_some_url(context) do | ||
{:ok, Map.put(context, :conn, get(context.conn, "/some_parent_path"))} | ||
{:ok, Map.put(context, :conn_with_url, get(context.conn, "/some_parent_path"))} | ||
end | ||
|
||
setup [:create_user, :log_in, :query_conn_with_some_url] | ||
|
@@ -966,7 +966,8 @@ defmodule PlausibleWeb.SiteControllerTest do | |
} do | ||
test "can toggle #{title} with admin access", %{ | ||
user: user, | ||
conn: conn0 | ||
conn: conn0, | ||
conn_with_url: conn_with_url | ||
} do | ||
site = | ||
insert(:site, | ||
|
@@ -979,7 +980,12 @@ defmodule PlausibleWeb.SiteControllerTest do | |
conn = | ||
put( | ||
conn0, | ||
PlausibleWeb.Components.Site.Feature.target(site, unquote(setting), conn0, false) | ||
PlausibleWeb.Components.Site.Feature.target( | ||
site, | ||
unquote(setting), | ||
conn_with_url, | ||
false | ||
) | ||
) | ||
|
||
assert Phoenix.Flash.get(conn.assigns.flash, :success) == | ||
|
@@ -992,7 +998,12 @@ defmodule PlausibleWeb.SiteControllerTest do | |
conn = | ||
put( | ||
conn0, | ||
PlausibleWeb.Components.Site.Feature.target(site, unquote(setting), conn0, true) | ||
PlausibleWeb.Components.Site.Feature.target( | ||
site, | ||
unquote(setting), | ||
conn_with_url, | ||
true | ||
) | ||
) | ||
|
||
assert Phoenix.Flash.get(conn.assigns.flash, :success) == | ||
|
@@ -1011,23 +1022,33 @@ defmodule PlausibleWeb.SiteControllerTest do | |
} do | ||
test "cannot toggle #{title} with viewer access", %{ | ||
user: user, | ||
conn: conn0 | ||
conn: conn0, | ||
conn_with_url: conn_with_url | ||
} do | ||
site = insert(:site) | ||
insert(:site_membership, user: user, site: site, role: :viewer) | ||
|
||
conn = | ||
put( | ||
conn0, | ||
PlausibleWeb.Components.Site.Feature.target(site, unquote(setting), conn0, false) | ||
PlausibleWeb.Components.Site.Feature.target( | ||
site, | ||
unquote(setting), | ||
conn_with_url, | ||
false | ||
) | ||
) | ||
|
||
assert conn.status == 404 | ||
assert conn.halted | ||
end | ||
end | ||
|
||
test "setting feature visibility is idempotent", %{user: user, conn: conn0} do | ||
test "setting feature visibility is idempotent", %{ | ||
user: user, | ||
conn: conn0, | ||
conn_with_url: conn_with_url | ||
} do | ||
site = insert(:site) | ||
insert(:site_membership, user: user, site: site, role: :admin) | ||
|
||
|
@@ -1036,7 +1057,7 @@ defmodule PlausibleWeb.SiteControllerTest do | |
conn = | ||
put( | ||
conn0, | ||
PlausibleWeb.Components.Site.Feature.target(site, setting, conn0, false) | ||
PlausibleWeb.Components.Site.Feature.target(site, setting, conn_with_url, false) | ||
) | ||
|
||
assert %{^setting => false} = Plausible.Sites.get_by_domain(site.domain) | ||
|
@@ -1045,7 +1066,7 @@ defmodule PlausibleWeb.SiteControllerTest do | |
conn = | ||
put( | ||
conn0, | ||
PlausibleWeb.Components.Site.Feature.target(site, setting, conn0, false) | ||
PlausibleWeb.Components.Site.Feature.target(site, setting, conn_with_url, false) | ||
) | ||
|
||
assert %{^setting => false} = Plausible.Sites.get_by_domain(site.domain) | ||
|
@@ -1132,11 +1153,11 @@ defmodule PlausibleWeb.SiteControllerTest do | |
site = insert(:site) | ||
insert(:weekly_report, site: site, recipients: ["[email protected]"]) | ||
|
||
conn = delete(conn, "/sites/#{site.domain}/weekly-report/recipients/[email protected]") | ||
assert conn.status == 404 | ||
conn1 = delete(conn, "/sites/#{site.domain}/weekly-report/recipients/[email protected]") | ||
assert conn1.status == 404 | ||
|
||
conn = delete(conn, "/sites/#{site.domain}/weekly-report/recipients/recipient%40email.com") | ||
assert conn.status == 404 | ||
conn2 = delete(conn, "/sites/#{site.domain}/weekly-report/recipients/recipient%40email.com") | ||
assert conn2.status == 404 | ||
|
||
report = Repo.get_by(Plausible.Site.WeeklyReport, site_id: site.id) | ||
assert [_] = report.recipients | ||
|
@@ -1215,11 +1236,13 @@ defmodule PlausibleWeb.SiteControllerTest do | |
site = insert(:site) | ||
insert(:monthly_report, site: site, recipients: ["[email protected]"]) | ||
|
||
conn = delete(conn, "/sites/#{site.domain}/monthly-report/recipients/[email protected]") | ||
assert conn.status == 404 | ||
conn1 = delete(conn, "/sites/#{site.domain}/monthly-report/recipients/[email protected]") | ||
assert conn1.status == 404 | ||
|
||
conn = delete(conn, "/sites/#{site.domain}/monthly-report/recipients/recipient%40email.com") | ||
assert conn.status == 404 | ||
conn2 = | ||
delete(conn, "/sites/#{site.domain}/monthly-report/recipients/recipient%40email.com") | ||
|
||
assert conn2.status == 404 | ||
|
||
report = Repo.get_by(Plausible.Site.MonthlyReport, site_id: site.id) | ||
assert [_] = report.recipients | ||
|
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