Add specs for AccountController.block and AccountController.unblock

This commit is contained in:
Egor Kislitsyn 2020-04-09 18:41:18 +04:00
parent e4195d4a68
commit 68a979b824
No known key found for this signature in database
GPG key ID: 1B49CB15B71E7805
3 changed files with 34 additions and 3 deletions

View file

@ -278,8 +278,35 @@ def unmute_operation do
}
end
def block_operation, do: :ok
def unblock_operation, do: :ok
def block_operation do
%Operation{
tags: ["accounts"],
summary: "Block",
operationId: "AccountController.block",
security: [%{"oAuth" => ["follow", "write:blocks"]}],
description:
"Block the given account. Clients should filter statuses from this account if received (e.g. due to a boost in the Home timeline)",
parameters: [%Reference{"$ref": "#/components/parameters/accountIdOrNickname"}],
responses: %{
200 => Operation.response("Relationship", "application/json", AccountRelationship)
}
}
end
def unblock_operation do
%Operation{
tags: ["accounts"],
summary: "Unblock",
operationId: "AccountController.unblock",
security: [%{"oAuth" => ["follow", "write:blocks"]}],
description: "Unblock the given account.",
parameters: [%Reference{"$ref": "#/components/parameters/accountIdOrNickname"}],
responses: %{
200 => Operation.response("Relationship", "application/json", AccountRelationship)
}
}
end
def follows_operation, do: :ok
def mutes_operation, do: :ok
def blocks_operation, do: :ok

View file

@ -96,7 +96,9 @@ defmodule Pleroma.Web.MastodonAPI.AccountController do
:follow,
:unfollow,
:mute,
:unmute
:unmute,
:block,
:unblock
]
)

View file

@ -819,10 +819,12 @@ test "blocking / unblocking a user" do
ret_conn = post(conn, "/api/v1/accounts/#{other_user.id}/block")
assert %{"id" => _id, "blocking" => true} = json_response(ret_conn, 200)
assert_schema(json_response(ret_conn, 200), "AccountRelationship", ApiSpec.spec())
conn = post(conn, "/api/v1/accounts/#{other_user.id}/unblock")
assert %{"id" => _id, "blocking" => false} = json_response(conn, 200)
assert_schema(json_response(ret_conn, 200), "AccountRelationship", ApiSpec.spec())
end
describe "create account by app" do