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:
parent
afdf557174
commit
be4be118a3
@ -22,8 +22,6 @@ compile:
|
||||
# Run tests (requires PostgreSQL running on localhost:5432)
|
||||
# Note: If you don't have PostgreSQL, you can skip tests with `make check`
|
||||
test: deps compile
|
||||
$(MISE_EXEC) mix ecto.create --quiet
|
||||
$(MISE_EXEC) mix ecto.migrate --quiet
|
||||
$(MISE_EXEC) mix test
|
||||
|
||||
# Format code
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
# Fixed test file with proper Accept headers for API tests
|
||||
# Firehose blog controller tests
|
||||
|
||||
defmodule FirehoseWeb.BlogTest do
|
||||
use FirehoseWeb.ConnCase
|
||||
|
||||
defp goto_engineering_page(conn, suffix \\ "") do
|
||||
defp visit_engineering_page(conn, suffix \\ "") do
|
||||
path = "/blog/engineering" <> suffix
|
||||
conn = get(conn, path)
|
||||
body = html_response(conn, 200)
|
||||
@ -12,7 +12,7 @@ defmodule FirehoseWeb.BlogTest do
|
||||
body
|
||||
end
|
||||
|
||||
defp goto_engineering_post_page(conn, suffix) do
|
||||
defp visit_engineering_path(conn, suffix) do
|
||||
path = "/blog/engineering" <> suffix
|
||||
conn = get(conn, path)
|
||||
body = html_response(conn, 200)
|
||||
@ -22,16 +22,16 @@ defmodule FirehoseWeb.BlogTest do
|
||||
|
||||
describe "engineering blog (HTML)" do
|
||||
test "GET /blog/engineering returns HTML index with layout", %{conn: conn} do
|
||||
goto_engineering_page(conn)
|
||||
visit_engineering_page(conn)
|
||||
end
|
||||
|
||||
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"
|
||||
end
|
||||
|
||||
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")
|
||||
end
|
||||
end
|
||||
@ -43,17 +43,17 @@ defmodule FirehoseWeb.BlogTest do
|
||||
end
|
||||
|
||||
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"
|
||||
end
|
||||
|
||||
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"
|
||||
end
|
||||
|
||||
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"
|
||||
end
|
||||
|
||||
|
||||
@ -14,10 +14,10 @@ defmodule Firehose.DataCase do
|
||||
this option is not recommended for other databases.
|
||||
"""
|
||||
|
||||
use ExUnit.CaseTemplate
|
||||
|
||||
alias Ecto.Adapters.SQL.Sandbox
|
||||
|
||||
use ExUnit.CaseTemplate
|
||||
|
||||
using do
|
||||
quote do
|
||||
alias Firehose.Repo
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user