diff --git a/articles/templates/articles/analytics.html b/articles/templates/articles/analytics.html index 97863ae..769a897 100644 --- a/articles/templates/articles/analytics.html +++ b/articles/templates/articles/analytics.html @@ -1,3 +1,3 @@ -{% if plausible_domain is not None %} +{% if plausible_domain is not None and not user.is_authenticated %} {% endif %} diff --git a/articles/tests/conftest.py b/articles/tests/conftest.py index 2113651..908e95a 100644 --- a/articles/tests/conftest.py +++ b/articles/tests/conftest.py @@ -6,13 +6,13 @@ from articles.models import Article, Page, User @pytest.fixture() @pytest.mark.django_db -def author(): +def author() -> User: return User.objects.create_user("gaugendre") @pytest.fixture() @pytest.mark.django_db -def published_article(author): +def published_article(author: User) -> Article: return Article.objects.create( title="Some interesting article title", status=Article.PUBLISHED, @@ -25,7 +25,7 @@ def published_article(author): @pytest.fixture() @pytest.mark.django_db -def published_page(author): +def published_page(author: User) -> Page: return Page.objects.create( title="Some interesting page title", status=Article.PUBLISHED, diff --git a/articles/tests/test_articles.py b/articles/tests/test_articles.py index 4891c07..847821f 100644 --- a/articles/tests/test_articles.py +++ b/articles/tests/test_articles.py @@ -59,3 +59,12 @@ def test_doesnt_have_plausible_if_unset(client: Client, settings): res = client.get(reverse("articles-list")) content = res.content.decode("utf-8") assert "https://plausible.augendre.info/js/plausible.js" not in content + + +@pytest.mark.django_db +def test_logged_in_user_doesnt_have_plausible(client: Client, author: User, settings): + client.force_login(author) + settings.PLAUSIBLE_DOMAIN = "gabnotes.org" + res = client.get(reverse("articles-list")) + content = res.content.decode("utf-8") + assert "https://plausible.augendre.info/js/plausible.js" not in content