berrypod/test/berrypod_web/plugs/broken_url_tracker_test.exs
jamey 6e57af82fc
All checks were successful
deploy / deploy (push) Successful in 3m30s
add URL redirects with ETS-cached plug, broken URL tracking, and admin UI
Redirects context with redirect/broken_url schemas, chain flattening,
ETS cache for fast lookups in the request pipeline. BrokenUrlTracker
plug logs 404s. Auto-redirect on product slug change via upsert_product
hook. Admin redirects page with active/broken tabs, manual create form.
RedirectPrunerWorker cleans up old broken URLs. 1227 tests passing.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 14:14:14 +00:00

27 lines
615 B
Elixir

defmodule BerrypodWeb.Plugs.BrokenUrlTrackerTest do
use BerrypodWeb.ConnCase, async: true
alias Berrypod.Redirects
setup do
Redirects.create_table()
:ok
end
test "records broken URL on 404", %{conn: conn} do
conn = get(conn, "/zz-nonexistent-path")
assert conn.status in [404, 500]
[broken_url] = Redirects.list_broken_urls()
assert broken_url.path == "/zz-nonexistent-path"
assert broken_url.recent_404_count == 1
end
test "skips static asset paths", %{conn: conn} do
get(conn, "/assets/missing-file.js")
assert Redirects.list_broken_urls() == []
end
end