2020-01-26 20:36:50 +00:00
|
|
|
defmodule Mobilizon.Web.PageControllerTest do
|
|
|
|
use Mobilizon.Web.ConnCase
|
2019-09-22 14:26:23 +00:00
|
|
|
|
2018-11-27 16:54:54 +00:00
|
|
|
import Mobilizon.Factory
|
2019-09-22 14:26:23 +00:00
|
|
|
|
2019-04-25 17:05:05 +00:00
|
|
|
alias Mobilizon.Actors.Actor
|
2022-04-06 13:49:42 +00:00
|
|
|
alias Mobilizon.Service.ActorSuspension
|
2023-12-01 11:06:18 +00:00
|
|
|
use Mobilizon.Web, :verified_routes
|
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
|
|
|
|
|
2020-10-12 10:16:36 +00:00
|
|
|
describe "GET /" do
|
|
|
|
test "GET /", %{conn: conn} do
|
|
|
|
conn = get(conn, "/")
|
|
|
|
assert html_response(conn, 200)
|
|
|
|
end
|
2017-12-08 08:58:14 +00:00
|
|
|
end
|
2018-11-27 16:54:54 +00:00
|
|
|
|
2020-10-12 10:16:36 +00:00
|
|
|
describe "GET /@actor" do
|
|
|
|
test "GET /@actor with existing group", %{conn: conn} do
|
|
|
|
actor = insert(:group)
|
|
|
|
conn = get(conn, Actor.build_url(actor.preferred_username, :page))
|
|
|
|
assert html_response(conn, 200) =~ actor.preferred_username
|
|
|
|
end
|
|
|
|
|
|
|
|
test "GET /@actor with existing person", %{conn: conn} do
|
|
|
|
actor = insert(:actor, visibility: :private)
|
|
|
|
conn = get(conn, Actor.build_url(actor.preferred_username, :page))
|
|
|
|
assert html_response(conn, 404)
|
|
|
|
end
|
|
|
|
|
|
|
|
test "GET /@actor with not existing group", %{conn: conn} do
|
|
|
|
conn = get(conn, Actor.build_url("not_existing", :page))
|
|
|
|
assert html_response(conn, 404)
|
|
|
|
end
|
2022-04-06 13:49:42 +00:00
|
|
|
|
|
|
|
test "GET /@actor when suspended", %{conn: conn} do
|
|
|
|
suspended = insert(:actor)
|
|
|
|
|
|
|
|
conn = get(conn, Actor.build_url(suspended.preferred_username, :page))
|
|
|
|
assert html_response(conn, 200)
|
|
|
|
|
|
|
|
ActorSuspension.suspend_actor(suspended)
|
|
|
|
|
|
|
|
conn = get(conn, Actor.build_url(suspended.preferred_username, :page))
|
|
|
|
assert html_response(conn, 404)
|
|
|
|
end
|
2019-03-05 09:13:19 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
test "GET /events/:uuid", %{conn: conn} do
|
2020-09-02 07:24:22 +00:00
|
|
|
event = insert(:event, visibility: :public)
|
2023-12-01 08:49:54 +00:00
|
|
|
conn = get(conn, url(~p"/events/#{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
|
|
|
|
|
2020-09-02 07:24:22 +00:00
|
|
|
test "GET /events/:uuid with unlisted event", %{conn: conn} do
|
|
|
|
event = insert(:event, visibility: :unlisted)
|
2023-12-01 08:49:54 +00:00
|
|
|
conn = get(conn, url(~p"/events/#{event.uuid}"))
|
2020-09-02 07:24:22 +00:00
|
|
|
assert html_response(conn, 200) =~ event.title
|
|
|
|
assert ["noindex"] == get_resp_header(conn, "x-robots-tag")
|
|
|
|
end
|
|
|
|
|
2019-03-05 09:13:19 +00:00
|
|
|
test "GET /events/:uuid with not existing event", %{conn: conn} do
|
2023-12-01 08:49:54 +00:00
|
|
|
conn = get(conn, ~p"/events/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)
|
2023-12-01 08:49:54 +00:00
|
|
|
conn = get(conn, url(~p"/events/#{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)
|
2023-12-01 08:49:54 +00:00
|
|
|
conn = get(conn, url(~p"/comments/#{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
|
2023-12-01 08:49:54 +00:00
|
|
|
conn = get(conn, ~p"/comments/not_existing_comment")
|
2019-04-26 07:56:25 +00:00
|
|
|
assert html_response(conn, 404)
|
|
|
|
end
|
|
|
|
|
|
|
|
test "GET /comments/:uuid with comment not public", %{conn: conn} do
|
|
|
|
comment = insert(:comment, visibility: :private)
|
2023-12-01 08:49:54 +00:00
|
|
|
conn = get(conn, url(~p"/comments/#{comment.uuid}"))
|
2019-04-26 07:56:25 +00:00
|
|
|
assert html_response(conn, 404)
|
|
|
|
end
|
2017-12-08 08:58:14 +00:00
|
|
|
end
|