From 08eba461df8883837e4eda10515afa529144bd5c Mon Sep 17 00:00:00 2001 From: Uku Taht Date: Wed, 26 Feb 2020 11:46:28 +0200 Subject: [PATCH] Fix issue with snippet code --- lib/plausible_web/controllers/site_controller.ex | 2 ++ .../plausible_web/controllers/site_controller_test.exs | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/lib/plausible_web/controllers/site_controller.ex b/lib/plausible_web/controllers/site_controller.ex index 367df4901..bfe8354dd 100644 --- a/lib/plausible_web/controllers/site_controller.ex +++ b/lib/plausible_web/controllers/site_controller.ex @@ -27,6 +27,8 @@ defmodule PlausibleWeb.SiteController do def add_snippet(conn, %{"website" => website}) do site = Sites.get_for_user!(conn.assigns[:current_user].id, website) + |> Repo.preload(:custom_domain) + conn |> assign(:skip_plausible_tracking, true) |> render("snippet.html", site: site, layout: {PlausibleWeb.LayoutView, "focus.html"}) diff --git a/test/plausible_web/controllers/site_controller_test.exs b/test/plausible_web/controllers/site_controller_test.exs index acbbbb65d..42afb61b4 100644 --- a/test/plausible_web/controllers/site_controller_test.exs +++ b/test/plausible_web/controllers/site_controller_test.exs @@ -63,6 +63,16 @@ defmodule PlausibleWeb.SiteControllerTest do end end + describe "GET /:website/snippet" do + setup [:create_user, :log_in, :create_site] + + test "shows snippet", %{conn: conn, site: site} do + conn = get(conn, "/#{site.domain}/snippet") + + assert html_response(conn, 200) =~ "Add javascript snippet" + end + end + describe "GET /:website/settings" do setup [:create_user, :log_in, :create_site]