2018-10-11 17:37:39 +02:00
|
|
|
defmodule MobilizonWeb.PageControllerTest do
|
|
|
|
use MobilizonWeb.ConnCase
|
2018-11-27 17:54:54 +01:00
|
|
|
import Mobilizon.Factory
|
2019-04-25 19:05:05 +02:00
|
|
|
alias Mobilizon.Actors.Actor
|
|
|
|
alias MobilizonWeb.Router.Helpers, as: Routes
|
|
|
|
alias MobilizonWeb.Endpoint
|
2017-12-08 09:58:14 +01:00
|
|
|
|
2019-03-05 10:13:19 +01:00
|
|
|
setup do
|
|
|
|
conn = build_conn() |> put_req_header("accept", "text/html")
|
|
|
|
{:ok, conn: conn}
|
|
|
|
end
|
|
|
|
|
2017-12-08 09:58:14 +01:00
|
|
|
test "GET /", %{conn: conn} do
|
2018-07-27 10:45:35 +02:00
|
|
|
conn = get(conn, "/")
|
2018-01-13 23:33:03 +01:00
|
|
|
assert html_response(conn, 200)
|
2017-12-08 09:58:14 +01:00
|
|
|
end
|
2018-11-27 17:54:54 +01:00
|
|
|
|
2019-03-05 10:13:19 +01:00
|
|
|
test "GET /@actor with existing actor", %{conn: conn} do
|
2018-11-27 17:54:54 +01:00
|
|
|
actor = insert(:actor)
|
2019-04-25 19:05:05 +02:00
|
|
|
conn = get(conn, Actor.build_url(actor.preferred_username, :page))
|
2018-11-27 17:54:54 +01:00
|
|
|
assert html_response(conn, 200)
|
|
|
|
end
|
2019-03-05 10:13:19 +01:00
|
|
|
|
|
|
|
test "GET /@actor with not existing actor", %{conn: conn} do
|
2019-04-25 19:05:05 +02:00
|
|
|
conn = get(conn, Actor.build_url("not_existing", :page))
|
2019-03-05 10:13:19 +01:00
|
|
|
assert html_response(conn, 404)
|
|
|
|
end
|
|
|
|
|
|
|
|
test "GET /events/:uuid", %{conn: conn} do
|
|
|
|
event = insert(:event)
|
2019-04-25 19:05:05 +02:00
|
|
|
conn = get(conn, Routes.page_url(Endpoint, :event, event.uuid))
|
2019-03-05 10:13:19 +01:00
|
|
|
assert html_response(conn, 200)
|
|
|
|
end
|
|
|
|
|
|
|
|
test "GET /events/:uuid with not existing event", %{conn: conn} do
|
2019-04-25 19:05:05 +02:00
|
|
|
conn = get(conn, Routes.page_url(Endpoint, :event, "not_existing_event"))
|
2019-03-05 10:13:19 +01:00
|
|
|
assert html_response(conn, 404)
|
|
|
|
end
|
|
|
|
|
|
|
|
test "GET /events/:uuid with event not public", %{conn: conn} do
|
|
|
|
event = insert(:event, visibility: :restricted)
|
2019-04-25 19:05:05 +02:00
|
|
|
conn = get(conn, Routes.page_url(Endpoint, :event, event.uuid))
|
2019-03-05 10:13:19 +01:00
|
|
|
assert html_response(conn, 404)
|
|
|
|
end
|
|
|
|
|
2019-04-26 09:56:25 +02:00
|
|
|
test "GET /comments/:uuid", %{conn: conn} do
|
|
|
|
comment = insert(:comment)
|
|
|
|
conn = get(conn, Routes.page_url(Endpoint, :comment, comment.uuid))
|
|
|
|
assert html_response(conn, 200)
|
|
|
|
end
|
|
|
|
|
|
|
|
test "GET /comments/:uuid with not existing comment", %{conn: conn} do
|
|
|
|
conn = get(conn, Routes.page_url(Endpoint, :comment, "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))
|
|
|
|
assert html_response(conn, 404)
|
|
|
|
end
|
2017-12-08 09:58:14 +01:00
|
|
|
end
|