aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEgor Kislitsyn <egor@kislitsyn.com>2020-04-09 17:57:21 +0400
committerEgor Kislitsyn <egor@kislitsyn.com>2020-04-13 18:17:08 +0400
commitaa958a6dda7cdcf12e9cd9232e7c6be421610317 (patch)
tree728d4f077b205ba5fbc3a4574bdf799c6a38afd4
parent854780c72bc90a55d7005a05861d45771c5aeadf (diff)
downloadpleroma-aa958a6dda7cdcf12e9cd9232e7c6be421610317.tar.gz
Add spec for AccountController.unfollow
-rw-r--r--lib/pleroma/web/api_spec/operations/account_operation.ex15
-rw-r--r--lib/pleroma/web/mastodon_api/controllers/account_controller.ex3
-rw-r--r--test/web/mastodon_api/controllers/account_controller_test.exs16
3 files changed, 28 insertions, 6 deletions
diff --git a/lib/pleroma/web/api_spec/operations/account_operation.ex b/lib/pleroma/web/api_spec/operations/account_operation.ex
index a76141f7a..8925ebefd 100644
--- a/lib/pleroma/web/api_spec/operations/account_operation.ex
+++ b/lib/pleroma/web/api_spec/operations/account_operation.ex
@@ -225,7 +225,20 @@ defmodule Pleroma.Web.ApiSpec.AccountOperation do
}
end
- def unfollow_operation, do: :ok
+ def unfollow_operation do
+ %Operation{
+ tags: ["accounts"],
+ summary: "Unfollow",
+ operationId: "AccountController.unfollow",
+ security: [%{"oAuth" => ["follow", "write:follows"]}],
+ description: "Unfollow the given account",
+ parameters: [%Reference{"$ref": "#/components/parameters/accountIdOrNickname"}],
+ responses: %{
+ 200 => Operation.response("Relationship", "application/json", AccountRelationship)
+ }
+ }
+ end
+
def mute_operation, do: :ok
def unmute_operation, do: :ok
def block_operation, do: :ok
diff --git a/lib/pleroma/web/mastodon_api/controllers/account_controller.ex b/lib/pleroma/web/mastodon_api/controllers/account_controller.ex
index d2ad65ef3..1ecce2928 100644
--- a/lib/pleroma/web/mastodon_api/controllers/account_controller.ex
+++ b/lib/pleroma/web/mastodon_api/controllers/account_controller.ex
@@ -93,7 +93,8 @@ defmodule Pleroma.Web.MastodonAPI.AccountController do
:followers,
:following,
:lists,
- :follow
+ :follow,
+ :unfollow
]
)
diff --git a/test/web/mastodon_api/controllers/account_controller_test.exs b/test/web/mastodon_api/controllers/account_controller_test.exs
index 7a3d58600..d56e7fb4a 100644
--- a/test/web/mastodon_api/controllers/account_controller_test.exs
+++ b/test/web/mastodon_api/controllers/account_controller_test.exs
@@ -660,10 +660,12 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
ret_conn = post(conn, "/api/v1/accounts/#{other_user.id}/follow")
assert %{"id" => _id, "following" => true} = json_response(ret_conn, 200)
+ assert_schema(json_response(ret_conn, 200), "AccountRelationship", ApiSpec.spec())
ret_conn = post(conn, "/api/v1/accounts/#{other_user.id}/unfollow")
assert %{"id" => _id, "following" => false} = json_response(ret_conn, 200)
+ assert_schema(json_response(ret_conn, 200), "AccountRelationship", ApiSpec.spec())
conn = post(conn, "/api/v1/follows", %{"uri" => other_user.nickname})
@@ -675,11 +677,15 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
test "cancelling follow request", %{conn: conn} do
%{id: other_user_id} = insert(:user, %{locked: true})
- assert %{"id" => ^other_user_id, "following" => false, "requested" => true} =
- conn |> post("/api/v1/accounts/#{other_user_id}/follow") |> json_response(:ok)
+ resp = conn |> post("/api/v1/accounts/#{other_user_id}/follow") |> json_response(:ok)
- assert %{"id" => ^other_user_id, "following" => false, "requested" => false} =
- conn |> post("/api/v1/accounts/#{other_user_id}/unfollow") |> json_response(:ok)
+ assert %{"id" => ^other_user_id, "following" => false, "requested" => true} = resp
+ assert_schema(resp, "AccountRelationship", ApiSpec.spec())
+
+ resp = conn |> post("/api/v1/accounts/#{other_user_id}/unfollow") |> json_response(:ok)
+
+ assert %{"id" => ^other_user_id, "following" => false, "requested" => false} = resp
+ assert_schema(resp, "AccountRelationship", ApiSpec.spec())
end
test "following without reblogs" do
@@ -690,6 +696,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
ret_conn = post(conn, "/api/v1/accounts/#{followed.id}/follow?reblogs=false")
assert %{"showing_reblogs" => false} = json_response(ret_conn, 200)
+ assert_schema(json_response(ret_conn, 200), "AccountRelationship", ApiSpec.spec())
{:ok, activity} = CommonAPI.post(other_user, %{"status" => "hey"})
{:ok, reblog, _} = CommonAPI.repeat(activity.id, followed)
@@ -701,6 +708,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
ret_conn = post(conn, "/api/v1/accounts/#{followed.id}/follow?reblogs=true")
assert %{"showing_reblogs" => true} = json_response(ret_conn, 200)
+ assert_schema(json_response(ret_conn, 200), "AccountRelationship", ApiSpec.spec())
conn = get(conn, "/api/v1/timelines/home")