Only render public comments

This commit is contained in:
Chocobozzz
2019-04-26 09:56:25 +02:00
parent 69974ff745
commit 25153d2ae1
4 changed files with 49 additions and 21 deletions

View File

@@ -69,17 +69,16 @@ defmodule MobilizonWeb.ActivityPubControllerTest do
ObjectView.render("comment.json", %{comment: comment |> Utils.make_comment_data()})
end
# TODO !
# test "it returns 404 for non-public comments", %{conn: conn} do
# event = insert(:event, public: false)
test "it returns 404 for non-public comments", %{conn: conn} do
comment = insert(:comment, visibility: :private)
# conn =
# conn
# |> put_req_header("accept", "application/activity+json")
# |> get("/events/#{event.uuid}")
conn =
conn
|> put_req_header("accept", "application/activity+json")
|> get(Routes.page_url(Endpoint, :comment, comment.uuid))
# assert json_response(conn, 404)
# end
assert json_response(conn, 404)
end
end
describe "/@:preferred_username/inbox" do

View File

@@ -43,5 +43,20 @@ defmodule MobilizonWeb.PageControllerTest do
assert html_response(conn, 404)
end
# TODO: Comments
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
end