summaryrefslogtreecommitdiff
path: root/test/web/common_api/common_api_test.exs
diff options
context:
space:
mode:
authorEgor Kislitsyn <egor@kislitsyn.com>2020-02-04 20:35:32 +0400
committerEgor Kislitsyn <egor@kislitsyn.com>2020-02-05 20:22:15 +0400
commit8c71f7e11a377d92234c141ea50170485e773fdc (patch)
tree9fc6579f7a07e92a3bd8dd9d2d6aee1f914fa6c3 /test/web/common_api/common_api_test.exs
parentc27d1d65bfd60effdb45359697141c136e156177 (diff)
downloadpleroma-8c71f7e11a377d92234c141ea50170485e773fdc.tar.gz
pleroma-8c71f7e11a377d92234c141ea50170485e773fdc.zip
Add support for cancellation of a follow request
Diffstat (limited to 'test/web/common_api/common_api_test.exs')
-rw-r--r--test/web/common_api/common_api_test.exs24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/web/common_api/common_api_test.exs b/test/web/common_api/common_api_test.exs
index 8fa0c6faa..2bbe6c923 100644
--- a/test/web/common_api/common_api_test.exs
+++ b/test/web/common_api/common_api_test.exs
@@ -536,6 +536,30 @@ defmodule Pleroma.Web.CommonAPITest do
refute User.subscribed_to?(follower, followed)
end
+
+ test "cancels a pending follow" do
+ follower = insert(:user)
+ followed = insert(:user, locked: true)
+
+ assert {:ok, follower, followed, %{id: activity_id, data: %{"state" => "pending"}}} =
+ CommonAPI.follow(follower, followed)
+
+ assert %{state: "pending"} = Pleroma.FollowingRelationship.get(follower, followed)
+
+ assert {:ok, follower} = CommonAPI.unfollow(follower, followed)
+
+ assert Pleroma.FollowingRelationship.get(follower, followed) == nil
+
+ assert %{id: ^activity_id, data: %{"state" => "cancelled"}} =
+ Pleroma.Web.ActivityPub.Utils.fetch_latest_follow(follower, followed)
+
+ assert %{
+ data: %{
+ "type" => "Undo",
+ "object" => %{"type" => "Follow", "state" => "cancelled"}
+ }
+ } = Pleroma.Web.ActivityPub.Utils.fetch_latest_undo(follower)
+ end
end
describe "accept_follow_request/2" do