Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.
TypeScript analyticsanalytics-dashboardclickhouseelixirgoogle-analyticsmarketingopen-source-analyticsphoenixplausible-analyticspostgresqlprivacyprivacy-friendlyself-hostedsimple-analyticsstatisticstailwindcssweb-analyticswebsite-analyticswebsite-statswebsite-tracking
Render an error on site creation with `domain=domain_changed_from` (#2821)
hq1406ea6f0cdee
diff --git a/lib/plausible/site.ex b/lib/plausible/site.exindex 114214920d..2f78d12916 100644--- a/lib/plausible/site.ex+++ b/lib/plausible/site.ex@@ -57,6 +57,10 @@ defmodule Plausible.Site do|> unique_constraint(:domain,message: @domain_unique_error)+ |> unique_constraint(:domain,+ name: "domain_change_disallowed",+ message: @domain_unique_error+ )enddef update_changeset(site, attrs \\ %{}, opts \\ []) dodiff --git a/test/plausible_web/controllers/site_controller_test.exs b/test/plausible_web/controllers/site_controller_test.exsindex 312126564c..19e28b7e95 100644--- a/test/plausible_web/controllers/site_controller_test.exs+++ b/test/plausible_web/controllers/site_controller_test.exs@@ -284,6 +284,23 @@ defmodule PlausibleWeb.SiteControllerTest doassert html_response(conn, 200) =~"This domain cannot be registered. Perhaps one of your colleagues registered it?"end++ test "renders form again when domain was changed from elsewhere", %{conn: conn} do+ :site+ |> insert(domain: "example.com")+ |> Plausible.Site.Domain.change("new.example.com")++ conn =+ post(conn, "/sites", %{+ "site" => %{+ "domain" => "example.com",+ "timezone" => "Europe/London"+ }+ })++ assert html_response(conn, 200) =~+ "This domain cannot be registered. Perhaps one of your colleagues registered it?"+ endenddescribe "GET /:website/snippet" do