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