aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorrinpatch <rinpatch@sdf.org>2019-08-09 16:49:09 +0300
committerAriadne Conill <ariadne@dereferenced.org>2019-08-14 01:50:21 +0000
commitdcd30e3cebc61c5b84cee123f450536003869dd0 (patch)
tree0da535998c44b932c34962d256aba3bb9dd36163 /test
parent9c499435f046d58b4a56605c190a890b070f5315 (diff)
downloadpleroma-dcd30e3cebc61c5b84cee123f450536003869dd0.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 de6aeec72..f8a354272 100644
--- a/test/web/mastodon_api/account_view_test.exs
+++ b/test/web/mastodon_api/account_view_test.exs
@@ -275,4 +275,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