Add a noindex HTTP header on unlisted resources

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2020-09-02 09:24:22 +02:00
parent 489fd74545
commit 93728cb9d7
2 changed files with 24 additions and 2 deletions

View File

@@ -30,11 +30,18 @@ defmodule Mobilizon.Web.PageControllerTest do
end
test "GET /events/:uuid", %{conn: conn} do
event = insert(:event)
event = insert(:event, visibility: :public)
conn = get(conn, Routes.page_url(Endpoint, :event, event.uuid))
assert html_response(conn, 200) =~ event.title
end
test "GET /events/:uuid with unlisted event", %{conn: conn} do
event = insert(:event, visibility: :unlisted)
conn = get(conn, Routes.page_url(Endpoint, :event, event.uuid))
assert html_response(conn, 200) =~ event.title
assert ["noindex"] == get_resp_header(conn, "x-robots-tag")
end
test "GET /events/:uuid with not existing event", %{conn: conn} do
conn = get(conn, Routes.page_url(Endpoint, :event, "not_existing_event"))
assert html_response(conn, 404)