2020-01-26 21:36:50 +01:00
|
|
|
defmodule Mobilizon.Web.PageControllerTest do
|
|
|
|
use Mobilizon.Web.ConnCase
|
2019-09-22 16:26:23 +02:00
|
|
|
|
2018-11-27 17:54:54 +01:00
|
|
|
import Mobilizon.Factory
|
2019-09-22 16:26:23 +02:00
|
|
|
|
2019-04-25 19:05:05 +02:00
|
|
|
alias Mobilizon.Actors.Actor
|
2019-09-22 16:26:23 +02:00
|
|
|
|
2020-01-26 21:36:50 +01:00
|
|
|
alias Mobilizon.Web.Endpoint
|
|
|
|
alias Mobilizon.Web.Router.Helpers, as: Routes
|
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
|
|
|
|
|
2020-10-12 12:16:36 +02:00
|
|
|
describe "GET /" do
|
|
|
|
test "GET /", %{conn: conn} do
|
|
|
|
conn = get(conn, "/")
|
|
|
|
assert html_response(conn, 200)
|
|
|
|
end
|
2017-12-08 09:58:14 +01:00
|
|
|
end
|
2018-11-27 17:54:54 +01:00
|
|
|
|
2020-10-12 12:16:36 +02: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
|
2019-03-05 10:13:19 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
test "GET /events/:uuid", %{conn: conn} do
|
2020-09-02 09:24:22 +02:00
|
|
|
event = insert(:event, visibility: :public)
|
2019-04-25 19:05:05 +02:00
|
|
|
conn = get(conn, Routes.page_url(Endpoint, :event, event.uuid))
|
2019-05-02 13:53:19 +02:00
|
|
|
assert html_response(conn, 200) =~ event.title
|
2019-03-05 10:13:19 +01:00
|
|
|
end
|
|
|
|
|
2020-09-02 09:24:22 +02:00
|
|
|
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))
|
|
|
|
assert html_response(conn, 200) =~ event.title
|
|
|
|
assert ["noindex"] == get_resp_header(conn, "x-robots-tag")
|
|
|
|
end
|
|
|
|
|
2019-03-05 10:13:19 +01:00
|
|
|
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))
|
2019-05-02 13:53:19 +02:00
|
|
|
assert html_response(conn, 200) =~ comment.text
|
2019-04-26 09:56:25 +02: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 09:58:14 +01:00
|
|
|
end
|