summaryrefslogtreecommitdiff
path: root/test/web/activity_pub/activity_pub_test.exs
diff options
context:
space:
mode:
authorRoman Chvanikov <chvanikoff@pm.me>2019-08-02 18:16:04 +0300
committerRoman Chvanikov <chvanikoff@pm.me>2019-08-02 18:16:04 +0300
commit9d4f34fbcb1a8e2eca424b3a3374c9f9af972574 (patch)
treec5943eb5d2652e08cc12d0b58a992376c425e66d /test/web/activity_pub/activity_pub_test.exs
parentd2da3d30f3349946500423bab53e0c1221ab7b9b (diff)
parent5ff8f07ca906d77a6ec1d5ba912a787f855364f9 (diff)
downloadpleroma-9d4f34fbcb1a8e2eca424b3a3374c9f9af972574.tar.gz
pleroma-9d4f34fbcb1a8e2eca424b3a3374c9f9af972574.zip
Merge branch 'develop' into feature/digest-email
Diffstat (limited to 'test/web/activity_pub/activity_pub_test.exs')
-rw-r--r--test/web/activity_pub/activity_pub_test.exs61
1 files changed, 61 insertions, 0 deletions
diff --git a/test/web/activity_pub/activity_pub_test.exs b/test/web/activity_pub/activity_pub_test.exs
index 1c0b274cb..3d9a678dd 100644
--- a/test/web/activity_pub/activity_pub_test.exs
+++ b/test/web/activity_pub/activity_pub_test.exs
@@ -1128,4 +1128,65 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
assert result.id == activity.id
end
end
+
+ describe "fetch_follow_information_for_user" do
+ test "syncronizes following/followers counters" do
+ user =
+ insert(:user,
+ local: false,
+ follower_address: "http://localhost:4001/users/fuser2/followers",
+ following_address: "http://localhost:4001/users/fuser2/following"
+ )
+
+ {:ok, info} = ActivityPub.fetch_follow_information_for_user(user)
+ assert info.follower_count == 527
+ assert info.following_count == 267
+ end
+
+ test "detects hidden followers" do
+ mock(fn env ->
+ case env.url do
+ "http://localhost:4001/users/masto_closed/followers?page=1" ->
+ %Tesla.Env{status: 403, body: ""}
+
+ _ ->
+ apply(HttpRequestMock, :request, [env])
+ end
+ end)
+
+ user =
+ insert(:user,
+ local: false,
+ follower_address: "http://localhost:4001/users/masto_closed/followers",
+ following_address: "http://localhost:4001/users/masto_closed/following"
+ )
+
+ {:ok, info} = ActivityPub.fetch_follow_information_for_user(user)
+ assert info.hide_followers == true
+ assert info.hide_follows == false
+ end
+
+ test "detects hidden follows" do
+ mock(fn env ->
+ case env.url do
+ "http://localhost:4001/users/masto_closed/following?page=1" ->
+ %Tesla.Env{status: 403, body: ""}
+
+ _ ->
+ apply(HttpRequestMock, :request, [env])
+ end
+ end)
+
+ user =
+ insert(:user,
+ local: false,
+ follower_address: "http://localhost:4001/users/masto_closed/followers",
+ following_address: "http://localhost:4001/users/masto_closed/following"
+ )
+
+ {:ok, info} = ActivityPub.fetch_follow_information_for_user(user)
+ assert info.hide_followers == false
+ assert info.hide_follows == true
+ end
+ end
end