refactor: use Phoenix verified routes
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
@@ -53,42 +53,42 @@ defmodule Mobilizon.Web.PageControllerTest do
|
||||
|
||||
test "GET /events/:uuid", %{conn: conn} do
|
||||
event = insert(:event, visibility: :public)
|
||||
conn = get(conn, Routes.page_url(Endpoint, :event, event.uuid))
|
||||
conn = get(conn, url(~p"/events/#{event.uuid}"))
|
||||
assert html_response(conn, 200) =~ event.title
|
||||
end
|
||||
|
||||
test "GET /events/:uuid with unlisted event", %{conn: conn} do
|
||||
event = insert(:event, visibility: :unlisted)
|
||||
conn = get(conn, Routes.page_url(Endpoint, :event, event.uuid))
|
||||
conn = get(conn, url(~p"/events/#{event.uuid}"))
|
||||
assert html_response(conn, 200) =~ event.title
|
||||
assert ["noindex"] == get_resp_header(conn, "x-robots-tag")
|
||||
end
|
||||
|
||||
test "GET /events/:uuid with not existing event", %{conn: conn} do
|
||||
conn = get(conn, Routes.page_url(Endpoint, :event, "not_existing_event"))
|
||||
conn = get(conn, ~p"/events/not_existing_event")
|
||||
assert html_response(conn, 404)
|
||||
end
|
||||
|
||||
test "GET /events/:uuid with event not public", %{conn: conn} do
|
||||
event = insert(:event, visibility: :restricted)
|
||||
conn = get(conn, Routes.page_url(Endpoint, :event, event.uuid))
|
||||
conn = get(conn, url(~p"/events/#{event.uuid}"))
|
||||
assert html_response(conn, 404)
|
||||
end
|
||||
|
||||
test "GET /comments/:uuid", %{conn: conn} do
|
||||
comment = insert(:comment)
|
||||
conn = get(conn, Routes.page_url(Endpoint, :comment, comment.uuid))
|
||||
conn = get(conn, url(~p"/comments/#{comment.uuid}"))
|
||||
assert html_response(conn, 200) =~ comment.text
|
||||
end
|
||||
|
||||
test "GET /comments/:uuid with not existing comment", %{conn: conn} do
|
||||
conn = get(conn, Routes.page_url(Endpoint, :comment, "not_existing_comment"))
|
||||
conn = get(conn, ~p"/comments/not_existing_comment")
|
||||
assert html_response(conn, 404)
|
||||
end
|
||||
|
||||
test "GET /comments/:uuid with comment not public", %{conn: conn} do
|
||||
comment = insert(:comment, visibility: :private)
|
||||
conn = get(conn, Routes.page_url(Endpoint, :comment, comment.uuid))
|
||||
conn = get(conn, url(~p"/comments/#{comment.uuid}"))
|
||||
assert html_response(conn, 404)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user