diff options
Diffstat (limited to 'test/pleroma/web/mastodon_api/controllers/account_controller_test.exs')
-rw-r--r-- | test/pleroma/web/mastodon_api/controllers/account_controller_test.exs | 41 |
1 files changed, 25 insertions, 16 deletions
diff --git a/test/pleroma/web/mastodon_api/controllers/account_controller_test.exs b/test/pleroma/web/mastodon_api/controllers/account_controller_test.exs index 828ebddd6..bba528d83 100644 --- a/test/pleroma/web/mastodon_api/controllers/account_controller_test.exs +++ b/test/pleroma/web/mastodon_api/controllers/account_controller_test.exs @@ -1845,12 +1845,9 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do setup do: clear_config([:instance, :max_endorsed_users], 1) test "pin account", %{user: user, conn: conn} do - %{id: id1} = insert(:user) + %{id: id1} = other_user1 = insert(:user) - conn - |> put_req_header("content-type", "application/json") - |> post("/api/v1/accounts/#{id1}/follow") - |> json_response_and_validate_schema(200) + CommonAPI.follow(user, other_user1) assert %{"id" => ^id1, "endorsed" => true} = conn @@ -1865,19 +1862,31 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do |> json_response_and_validate_schema(200) end - test "max pinned accounts", %{user: user, conn: conn} do - %{id: id1} = insert(:user) - %{id: id2} = insert(:user) + test "unpin account", %{user: user, conn: conn} do + %{id: id1} = other_user1 = insert(:user) - conn - |> put_req_header("content-type", "application/json") - |> post("/api/v1/accounts/#{id1}/follow") - |> json_response_and_validate_schema(200) + CommonAPI.follow(user, other_user1) + User.endorse(user, other_user1) - conn - |> put_req_header("content-type", "application/json") - |> post("/api/v1/accounts/#{id2}/follow") - |> json_response_and_validate_schema(200) + assert %{"id" => ^id1, "endorsed" => false} = + conn + |> put_req_header("content-type", "application/json") + |> post("/api/v1/accounts/#{id1}/unpin") + |> json_response_and_validate_schema(200) + + assert [] = + 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} = other_user1 = insert(:user) + %{id: id2} = other_user2 = insert(:user) + + CommonAPI.follow(user, other_user1) + CommonAPI.follow(user, other_user2) conn |> put_req_header("content-type", "application/json") |