Merge branch 'develop' of git.pleroma.social:pleroma/pleroma into bugfix/1442-dont...
authorlain <lain@soykaf.club>
Wed, 27 Nov 2019 13:48:28 +0000 (14:48 +0100)
committerlain <lain@soykaf.club>
Wed, 27 Nov 2019 13:48:28 +0000 (14:48 +0100)
1  2 
lib/pleroma/web/mastodon_api/views/account_view.ex
test/web/mastodon_api/views/account_view_test.exs

index e30fed6102b7b16a491cfc0f6010df1570371025,7f50f3aa692efc38a666c8f19f874aa8e4ff67b2..1068f8823f0ecd464963f84976220f91c5f9a9ff
@@@ -74,15 -74,14 +74,14 @@@ defmodule Pleroma.Web.MastodonAPI.Accou
  
      following_count =
        if !user.hide_follows_count or !user.hide_follows or opts[:for] == user do
-         user_info.following_count
 -        user.following_count
++        user.following_count || 0
        else
          0
        end
  
      followers_count =
        if !user.hide_followers_count or !user.hide_followers or opts[:for] == user do
-         user_info.follower_count
 -        user.follower_count
++        user.follower_count || 0
        else
          0
        end
index af88841ed234c5f8ba87a49312a79abe302247fe,15bfcbb78ccec56c0be9025178af76846dbc6582..d147079ab603f3e2b2592c25dfaa2eda2feb045b
@@@ -374,6 -375,6 +375,14 @@@ defmodule Pleroma.Web.MastodonAPI.Accou
      refute result.display_name == "<marquee> username </marquee>"
    end
  
++  test "never display nil user follow counts" do
++    user = insert(:user, following_count: 0, follower_count: 0)
++    result = AccountView.render("show.json", %{user: user})
++
++    assert result.following_count == 0
++    assert result.followers_count == 0
++  end
++
    describe "hiding follows/following" do
      test "shows when follows/followers stats are hidden and sets follow/follower count to 0" do
        user =