diff options
Diffstat (limited to 'test/web/mastodon_api')
-rw-r--r-- | test/web/mastodon_api/account_view_test.exs | 3 | ||||
-rw-r--r-- | test/web/mastodon_api/mastodon_api_controller_test.exs | 36 |
2 files changed, 36 insertions, 3 deletions
diff --git a/test/web/mastodon_api/account_view_test.exs b/test/web/mastodon_api/account_view_test.exs index aa74ed966..c62cb4f36 100644 --- a/test/web/mastodon_api/account_view_test.exs +++ b/test/web/mastodon_api/account_view_test.exs @@ -51,12 +51,13 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do other_user = insert(:user) {:ok, user} = User.follow(user, other_user) + {:ok, user} = User.block(user, other_user) expected = %{ id: other_user.id, following: true, followed_by: false, - blocking: false, + blocking: true, muting: false, requested: false, domain_blocking: false diff --git a/test/web/mastodon_api/mastodon_api_controller_test.exs b/test/web/mastodon_api/mastodon_api_controller_test.exs index cf09bc4b8..d118026eb 100644 --- a/test/web/mastodon_api/mastodon_api_controller_test.exs +++ b/test/web/mastodon_api/mastodon_api_controller_test.exs @@ -291,11 +291,43 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do assert id == other_user.id end - test "unimplemented block/mute endpoints" do + test "blocking / unblocking a user", %{conn: conn} do user = insert(:user) other_user = insert(:user) - ["block", "unblock", "mute", "unmute"] + conn = conn + |> assign(:user, user) + |> post("/api/v1/accounts/#{other_user.id}/block") + + assert %{"id" => id, "blocking" => true} = json_response(conn, 200) + + user = Repo.get(User, user.id) + conn = build_conn() + |> assign(:user, user) + |> post("/api/v1/accounts/#{other_user.id}/unblock") + + assert %{"id" => id, "blocking" => false} = json_response(conn, 200) + end + + test "getting a list of blocks", %{conn: conn} do + user = insert(:user) + other_user = insert(:user) + + {:ok, user} = User.block(user, other_user) + + conn = conn + |> assign(:user, user) + |> get("/api/v1/blocks") + + other_user_id = other_user.id + assert [%{"id" => ^other_user_id}] = json_response(conn, 200) + end + + test "unimplemented mute endpoints" do + user = insert(:user) + other_user = insert(:user) + + ["mute", "unmute"] |> Enum.each(fn(endpoint) -> conn = build_conn() |> assign(:user, user) |