mirror of
https://github.com/TheRealOwenRees/chess-endgame-trainer.git
synced 2026-11-18 03:32:06 +00:00
Serve a runtime sitemap.xml with the indexable marketing pages only; endgame play pages are left out to avoid indexing tens of thousands of near-identical pages. Generate robots.txt at runtime so it points at the sitemap on the deployment's host, and send X-Robots-Tag: noindex from every /admin response.
23 lines
654 B
Elixir
23 lines
654 B
Elixir
defmodule ChesstrainerWeb.RobotsControllerTest do
|
|
use ChesstrainerWeb.ConnCase, async: true
|
|
|
|
alias ChesstrainerWeb.Endpoint
|
|
|
|
describe "GET /robots.txt" do
|
|
test "allows crawlers and points at the sitemap", %{conn: conn} do
|
|
body = conn |> get(~p"/robots.txt") |> response(200)
|
|
|
|
assert body =~ "User-agent: *"
|
|
assert body =~ "Allow: /"
|
|
assert body =~ "Sitemap: #{Endpoint.url()}/sitemap.xml"
|
|
end
|
|
|
|
test "is served as plain text", %{conn: conn} do
|
|
conn = get(conn, ~p"/robots.txt")
|
|
|
|
assert [content_type] = get_resp_header(conn, "content-type")
|
|
assert content_type =~ "text/plain"
|
|
end
|
|
end
|
|
end
|