aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorrinpatch <rinpatch@sdf.org>2019-08-09 16:49:09 +0300
committerrinpatch <rinpatch@sdf.org>2019-08-09 16:53:55 +0300
commit409bcad54b5de631536761952faed05ad5fe3b99 (patch)
tree9cd535049299204fd906d99638ccc5b8ee1da4b6 /test
parent29807ef6a5b43a528ffca08b4f721b251f331c8d (diff)
downloadpleroma-409bcad54b5de631536761952faed05ad5fe3b99.tar.gz
Mastodon API: Set follower/following counters to 0 when hiding
followers/following is enabled We are already doing that in AP representation, so I think we should do it here as well for consistency.
Diffstat (limited to 'test')
-rw-r--r--test/web/mastodon_api/account_view_test.exs27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/web/mastodon_api/account_view_test.exs b/test/web/mastodon_api/account_view_test.exs
index 905e9af98..a26f514a5 100644
--- a/test/web/mastodon_api/account_view_test.exs
+++ b/test/web/mastodon_api/account_view_test.exs
@@ -356,4 +356,31 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
result = AccountView.render("account.json", %{user: user})
refute result.display_name == "<marquee> username </marquee>"
end
+
+ describe "hiding follows/following" do
+ test "shows when follows/following are hidden and sets follower/following count to 0" do
+ user = insert(:user, info: %{hide_followers: true, hide_follows: true})
+ other_user = insert(:user)
+ {:ok, user, other_user, _activity} = CommonAPI.follow(user, other_user)
+ {:ok, _other_user, user, _activity} = CommonAPI.follow(other_user, user)
+
+ assert %{
+ followers_count: 0,
+ following_count: 0,
+ pleroma: %{hide_follows: true, hide_followers: true}
+ } = AccountView.render("account.json", %{user: user})
+ end
+
+ test "shows actual follower/following count to the account owner" do
+ user = insert(:user, info: %{hide_followers: true, hide_follows: true})
+ other_user = insert(:user)
+ {:ok, user, other_user, _activity} = CommonAPI.follow(user, other_user)
+ {:ok, _other_user, user, _activity} = CommonAPI.follow(other_user, user)
+
+ assert %{
+ followers_count: 1,
+ following_count: 1
+ } = AccountView.render("account.json", %{user: user, for: user})
+ end
+ end
end