Skip to content
Snippets Groups Projects
Unverified Commit 63b807cf authored by Claire's avatar Claire Committed by GitHub
Browse files

Fix serialization of followers/following counts when user hides their network (#16418)


* Add tests

* Fix serialization of followers/following counts when user hides their network

Fixes #16382

Signed-off-by: default avatarClaire <claire.github-309c@sitedethib.com>
parent d174d12c
No related branches found
No related tags found
No related merge requests found
......@@ -85,7 +85,7 @@ class FollowerAccountsController < ApplicationController
if page_requested? || !@account.user_hides_network?
# Return all fields
else
%i(id type totalItems)
%i(id type total_items)
end
end
end
......@@ -85,7 +85,7 @@ class FollowingAccountsController < ApplicationController
if page_requested? || !@account.user_hides_network?
# Return all fields
else
%i(id type totalItems)
%i(id type total_items)
end
end
end
......@@ -3,7 +3,7 @@ require 'rails_helper'
describe FollowerAccountsController do
render_views
let(:alice) { Fabricate(:account, username: 'alice') }
let(:alice) { Fabricate(:user).account }
let(:follower0) { Fabricate(:account) }
let(:follower1) { Fabricate(:account) }
......@@ -101,6 +101,23 @@ describe FollowerAccountsController do
expect(body['partOf']).to be_blank
end
context 'when account hides their network' do
before do
alice.user.settings.hide_network = true
end
it 'returns followers count' do
expect(body['totalItems']).to eq 2
end
it 'does not return items' do
expect(body['items']).to be_blank
expect(body['orderedItems']).to be_blank
expect(body['first']).to be_blank
expect(body['last']).to be_blank
end
end
context 'when account is permanently suspended' do
before do
alice.suspend!
......
......@@ -3,7 +3,7 @@ require 'rails_helper'
describe FollowingAccountsController do
render_views
let(:alice) { Fabricate(:account, username: 'alice') }
let(:alice) { Fabricate(:user).account }
let(:followee0) { Fabricate(:account) }
let(:followee1) { Fabricate(:account) }
......@@ -101,6 +101,23 @@ describe FollowingAccountsController do
expect(body['partOf']).to be_blank
end
context 'when account hides their network' do
before do
alice.user.settings.hide_network = true
end
it 'returns followers count' do
expect(body['totalItems']).to eq 2
end
it 'does not return items' do
expect(body['items']).to be_blank
expect(body['orderedItems']).to be_blank
expect(body['first']).to be_blank
expect(body['last']).to be_blank
end
end
context 'when account is permanently suspended' do
before do
alice.suspend!
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment