WIP account endorsements
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
parent
4f249b2397
commit
0f90fd5805
11 changed files with 107 additions and 51 deletions
|
|
@ -1838,4 +1838,57 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
|||
|> get("/api/v1/accounts/relationships?id=#{other_user.id}")
|
||||
|> json_response_and_validate_schema(200)
|
||||
end
|
||||
|
||||
describe "account endorsements" do
|
||||
setup do: oauth_access(["read:accounts", "write:accounts", "write:follows"])
|
||||
|
||||
setup do: clear_config([:instance, :max_endorsed_users], 1)
|
||||
|
||||
test "pin account", %{user: user, conn: conn} do
|
||||
%{id: id1} = insert(:user)
|
||||
|
||||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> post("/api/v1/accounts/#{id1}/follow")
|
||||
|> json_response_and_validate_schema(200)
|
||||
|
||||
assert %{"id" => ^id1, "endorsed" => true} =
|
||||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> post("/api/v1/accounts/#{id1}/pin")
|
||||
|> json_response_and_validate_schema(200)
|
||||
|
||||
assert [%{"id" => ^id1}] =
|
||||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> get("/api/v1/endorsements")
|
||||
|> json_response_and_validate_schema(200)
|
||||
end
|
||||
|
||||
test "max pinned accounts", %{user: user, conn: conn} do
|
||||
%{id: id1} = insert(:user)
|
||||
%{id: id2} = insert(:user)
|
||||
|
||||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> post("/api/v1/accounts/#{id1}/follow")
|
||||
|> json_response_and_validate_schema(200)
|
||||
|
||||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> post("/api/v1/accounts/#{id2}/follow")
|
||||
|> json_response_and_validate_schema(200)
|
||||
|
||||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> post("/api/v1/accounts/#{id1}/pin")
|
||||
|> json_response_and_validate_schema(200)
|
||||
|
||||
assert %{"error" => "You have already pinned the maximum number of users"} =
|
||||
conn
|
||||
|> assign(:user, user)
|
||||
|> post("/api/v1/accounts/#{id2}/pin")
|
||||
|> json_response_and_validate_schema(400)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue