1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.PleromaAPI.StatusControllerTest do
6 use Pleroma.Web.ConnCase
8 alias Pleroma.Web.CommonAPI
10 import Pleroma.Factory
12 describe "getting quotes of a specified post" do
14 [current_user, user] = insert_pair(:user)
15 %{user: current_user, conn: conn} = oauth_access(["read:statuses"], user: current_user)
16 [current_user: current_user, user: user, conn: conn]
19 test "shows quotes of a post", %{conn: conn} do
21 activity = insert(:note_activity)
23 {:ok, quote_post} = CommonAPI.post(user, %{status: "quoat", quote_id: activity.id})
27 |> get("/api/v1/pleroma/statuses/#{activity.id}/quotes")
28 |> json_response_and_validate_schema(:ok)
32 assert length(response) == 1
33 assert status["id"] == quote_post.id
36 test "returns 404 error when a post can't be seen", %{conn: conn} do
37 activity = insert(:direct_note_activity)
41 |> get("/api/v1/pleroma/statuses/#{activity.id}/quotes")
43 assert json_response_and_validate_schema(response, 404) == %{"error" => "Record not found"}
46 test "returns 404 error when a post does not exist", %{conn: conn} do
49 |> get("/api/v1/pleroma/statuses/idontexist/quotes")
51 assert json_response_and_validate_schema(response, 404) == %{"error" => "Record not found"}