analytics/test/plausible_web/controllers/unsubscribe_controller_test.exs
hq1 a4b9c3b8ba
Remove custom domains support + update build options (#3559)
* Disable super-admin checks on small build

* Mute a test writing to stdout

* Move sampling outside of small build

* Convert waiting_first_pageview to heex and stop relying on env vars

* Set site limit unlimited on small build

* Stop relying on app env to get trial expiry

* Remove custom domains - including migration

* Remove is_selfhosted from layout view

* Quota fixup

* Stop relying on app env for self hosted registration

* Stop relying on app env for pass reset success

* Apply on_trial? check only on full build

* Update templates relying on app env

* Adjusts auth controller tests for small build

* Trial fixup

* Fixup

* Stop relying on app env

* Rest of the fsckn owl

* Update typespecs

* Fix dialyzer warning

* Remove unused module

* Credo + format

* GeoIP is not, for full build

* Use `small_build?()` where applicable

* Implement bypassing FirstLaunchPlug without insertions

* Get Marko's patch de58a18a85

* Test is-dbip=false presence

* Fix typespec

* Remove future hardcodes

* Handle `nil` from `Plausible.Geo.database_type()`

* Remove XXX marker

* Use one typespec for two clauses

* Introduce `MIX_ENV=small_dev`

* Revert "Use one typespec for two clauses"

This reverts commit 8d8cd21764.
2023-11-29 11:04:54 +01:00

51 lines
1.8 KiB
Elixir

defmodule PlausibleWeb.UnsubscribeControllerTest do
use PlausibleWeb.ConnCase, async: true
use Plausible.Repo
setup {PlausibleWeb.FirstLaunchPlug.Test, :skip}
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