add URL redirects with ETS-cached plug, broken URL tracking, and admin UI
All checks were successful
deploy / deploy (push) Successful in 3m30s
All checks were successful
deploy / deploy (push) Successful in 3m30s
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>
This commit is contained in:
26
test/berrypod_web/plugs/broken_url_tracker_test.exs
Normal file
26
test/berrypod_web/plugs/broken_url_tracker_test.exs
Normal file
@@ -0,0 +1,26 @@
|
||||
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
|
||||
Reference in New Issue
Block a user