mirror of
https://github.com/plausible/analytics.git
synced 2024-12-24 10:02:10 +03:00
5de43b758d
* Set pg pool size for MIX_ENV=test
* Include slow tests in CI run
* Exclude slow tests by default
* Mark tests slow/async where applicable
* Restructure captcha mocks
* Revert async where env is relied upon
* Add --max-failures=1 to CI run
* Set warnings as errors
* Disable async where various mocks are used
* Revert "Disable async where various mocks are used"
This reverts commit 2446b72a29
.
* Disable async for test using vcr
49 lines
1.8 KiB
Elixir
49 lines
1.8 KiB
Elixir
defmodule PlausibleWeb.UnsubscribeControllerTest do
|
|
use PlausibleWeb.ConnCase, async: true
|
|
use Plausible.Repo
|
|
|
|
describe "GET /sites/:website/weekly-report/unsubscribe" do
|
|
test "removes a recipient from the weekly report without them having to log in", %{conn: conn} do
|
|
site = insert(:site)
|
|
insert(:weekly_report, site: site, recipients: ["recipient@email.com"])
|
|
|
|
conn =
|
|
get(conn, "/sites/#{site.domain}/weekly-report/unsubscribe?email=recipient@email.com")
|
|
|
|
assert html_response(conn, 200) =~ "Unsubscribe successful"
|
|
|
|
report = Repo.get_by(Plausible.Site.WeeklyReport, site_id: site.id)
|
|
assert report.recipients == []
|
|
end
|
|
|
|
test "renders success if site or weekly report does not exist in the database", %{conn: conn} do
|
|
conn =
|
|
get(conn, "/sites/nonexistent.com/weekly-report/unsubscribe?email=recipient@email.com")
|
|
|
|
assert html_response(conn, 200) =~ "Unsubscribe successful"
|
|
end
|
|
end
|
|
|
|
describe "GET /sites/:website/monthly-report/unsubscribe" do
|
|
test "removes a recipient from the weekly report without them having to log in", %{conn: conn} do
|
|
site = insert(:site)
|
|
insert(:monthly_report, site: site, recipients: ["recipient@email.com"])
|
|
|
|
conn =
|
|
get(conn, "/sites/#{site.domain}/monthly-report/unsubscribe?email=recipient@email.com")
|
|
|
|
assert html_response(conn, 200) =~ "Unsubscribe successful"
|
|
|
|
report = Repo.get_by(Plausible.Site.MonthlyReport, site_id: site.id)
|
|
assert report.recipients == []
|
|
end
|
|
|
|
test "renders success if site or weekly report does not exist in the database", %{conn: conn} do
|
|
conn =
|
|
get(conn, "/sites/nonexistent.com/monthly-report/unsubscribe?email=recipient@email.com")
|
|
|
|
assert html_response(conn, 200) =~ "Unsubscribe successful"
|
|
end
|
|
end
|
|
end
|