Fix review issues from commit 2a21d75

1. Rename goto_engineering_post_page/2 to visit_engineering_path/2 for
   better accuracy (used for both post pages and tag pages)

2. Simplify Makefile test target by removing explicit ecto.create and
   ecto.migrate commands (mix test handles migrations automatically)

3. Update blog_test.exs header comment to reflect actual changes made

4. Move Sandbox alias to top level in data_case.ex
This commit is contained in:
Firehose Bot 2026-03-19 11:07:17 +00:00
parent afdf557174
commit be4be118a3
3 changed files with 11 additions and 13 deletions

View File

@ -22,8 +22,6 @@ compile:
# Run tests (requires PostgreSQL running on localhost:5432) # Run tests (requires PostgreSQL running on localhost:5432)
# Note: If you don't have PostgreSQL, you can skip tests with `make check` # Note: If you don't have PostgreSQL, you can skip tests with `make check`
test: deps compile test: deps compile
$(MISE_EXEC) mix ecto.create --quiet
$(MISE_EXEC) mix ecto.migrate --quiet
$(MISE_EXEC) mix test $(MISE_EXEC) mix test
# Format code # Format code

View File

@ -1,9 +1,9 @@
# Fixed test file with proper Accept headers for API tests # Firehose blog controller tests
defmodule FirehoseWeb.BlogTest do defmodule FirehoseWeb.BlogTest do
use FirehoseWeb.ConnCase use FirehoseWeb.ConnCase
defp goto_engineering_page(conn, suffix \\ "") do defp visit_engineering_page(conn, suffix \\ "") do
path = "/blog/engineering" <> suffix path = "/blog/engineering" <> suffix
conn = get(conn, path) conn = get(conn, path)
body = html_response(conn, 200) body = html_response(conn, 200)
@ -12,7 +12,7 @@ defmodule FirehoseWeb.BlogTest do
body body
end end
defp goto_engineering_post_page(conn, suffix) do defp visit_engineering_path(conn, suffix) do
path = "/blog/engineering" <> suffix path = "/blog/engineering" <> suffix
conn = get(conn, path) conn = get(conn, path)
body = html_response(conn, 200) body = html_response(conn, 200)
@ -22,16 +22,16 @@ defmodule FirehoseWeb.BlogTest do
describe "engineering blog (HTML)" do describe "engineering blog (HTML)" do
test "GET /blog/engineering returns HTML index with layout", %{conn: conn} do test "GET /blog/engineering returns HTML index with layout", %{conn: conn} do
goto_engineering_page(conn) visit_engineering_page(conn)
end end
test "GET /blog/engineering/:slug returns HTML post with layout", %{conn: conn} do test "GET /blog/engineering/:slug returns HTML post with layout", %{conn: conn} do
body = goto_engineering_post_page(conn, "/hello-world") body = visit_engineering_path(conn, "/hello-world")
assert body =~ "Hello World" assert body =~ "Hello World"
end end
test "GET /blog/engineering/tag/:tag returns HTML tag page", %{conn: conn} do test "GET /blog/engineering/tag/:tag returns HTML tag page", %{conn: conn} do
body = goto_engineering_post_page(conn, "/tag/elixir") body = visit_engineering_path(conn, "/tag/elixir")
assert body =~ ~s(tagged "elixir") assert body =~ ~s(tagged "elixir")
end end
end end
@ -43,17 +43,17 @@ defmodule FirehoseWeb.BlogTest do
end end
test "GET /blog/engineering?page=abc falls back to page 1", %{conn: conn} do test "GET /blog/engineering?page=abc falls back to page 1", %{conn: conn} do
body = goto_engineering_page(conn, "") body = visit_engineering_page(conn, "")
assert body =~ "Engineering Blog" assert body =~ "Engineering Blog"
end end
test "GET /blog/engineering?page=-1 falls back to page 1", %{conn: conn} do test "GET /blog/engineering?page=-1 falls back to page 1", %{conn: conn} do
body = goto_engineering_page(conn, "") body = visit_engineering_page(conn, "")
assert body =~ "Engineering Blog" assert body =~ "Engineering Blog"
end end
test "GET /blog/engineering?page=0 falls back to page 1", %{conn: conn} do test "GET /blog/engineering?page=0 falls back to page 1", %{conn: conn} do
body = goto_engineering_page(conn, "?page=0") body = visit_engineering_page(conn, "?page=0")
assert body =~ "Engineering Blog" assert body =~ "Engineering Blog"
end end

View File

@ -14,10 +14,10 @@ defmodule Firehose.DataCase do
this option is not recommended for other databases. this option is not recommended for other databases.
""" """
use ExUnit.CaseTemplate
alias Ecto.Adapters.SQL.Sandbox alias Ecto.Adapters.SQL.Sandbox
use ExUnit.CaseTemplate
using do using do
quote do quote do
alias Firehose.Repo alias Firehose.Repo