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
Make sure goal changeset error can be handled outside transaction (#5076)
Uku Taht7ae88c2c97ce
diff --git a/lib/plausible/goals/goals.ex b/lib/plausible/goals/goals.exindex c3229c96d6..800e201194 100644--- a/lib/plausible/goals/goals.ex+++ b/lib/plausible/goals/goals.ex@@ -68,6 +68,12 @@ defmodule Plausible.Goals doelseupdated_goalend+ else+ {:error, %Ecto.Changeset{} = changeset} ->+ Repo.rollback(changeset)++ {:error, :upgrade_required} ->+ Repo.rollback(:upgrade_required)endend)enddiff --git a/test/plausible_web/live/goal_settings/form_test.exs b/test/plausible_web/live/goal_settings/form_test.exsindex fee362210a..f6a97f4382 100644--- a/test/plausible_web/live/goal_settings/form_test.exs+++ b/test/plausible_web/live/goal_settings/form_test.exs@@ -278,6 +278,24 @@ defmodule PlausibleWeb.Live.GoalSettings.FormTest doassert updated.display_name == "Visit /updated"assert updated.id == g.idend++ test "renders error when goal is invalid", %{conn: conn, site: site} do+ {:ok, [g, g2, _]} = setup_goals(site)+ lv = get_liveview(conn, site)++ lv |> element(~s/button#edit-goal-#{g.id}/) |> render_click()++ html = render(lv)+ assert element_exists?(html, ~s|#page_path_input_modalseq0[value="/go/to/blog/**"|)++ lv+ |> element("#goals-form-modalseq0 form")+ |> render_submit(%{goal: %{page_path: "/updated", display_name: g2.display_name}})++ html = render(lv)++ assert html =~ "has already been taken"+ endenddescribe "Combos integration" do