Browse Source

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: Claire <claire.github-309c@sitedethib.com>
closed-social-v3
Claire 2 years ago
committed by Eugen Rochko
parent
commit
aebcb722aa
4 changed files with 38 additions and 4 deletions
  1. +1
    -1
      app/controllers/follower_accounts_controller.rb
  2. +1
    -1
      app/controllers/following_accounts_controller.rb
  3. +18
    -1
      spec/controllers/follower_accounts_controller_spec.rb
  4. +18
    -1
      spec/controllers/following_accounts_controller_spec.rb

+ 1
- 1
app/controllers/follower_accounts_controller.rb View File

@ -85,7 +85,7 @@ class FollowerAccountsController < ApplicationController
if page_requested? || !@account.user_hides_network? if page_requested? || !@account.user_hides_network?
# Return all fields # Return all fields
else else
%i(id type totalItems)
%i(id type total_items)
end end
end end
end end

+ 1
- 1
app/controllers/following_accounts_controller.rb View File

@ -85,7 +85,7 @@ class FollowingAccountsController < ApplicationController
if page_requested? || !@account.user_hides_network? if page_requested? || !@account.user_hides_network?
# Return all fields # Return all fields
else else
%i(id type totalItems)
%i(id type total_items)
end end
end end
end end

+ 18
- 1
spec/controllers/follower_accounts_controller_spec.rb View File

@ -3,7 +3,7 @@ require 'rails_helper'
describe FollowerAccountsController do describe FollowerAccountsController do
render_views render_views
let(:alice) { Fabricate(:account, username: 'alice') }
let(:alice) { Fabricate(:user).account }
let(:follower0) { Fabricate(:account) } let(:follower0) { Fabricate(:account) }
let(:follower1) { Fabricate(:account) } let(:follower1) { Fabricate(:account) }
@ -101,6 +101,23 @@ describe FollowerAccountsController do
expect(body['partOf']).to be_blank expect(body['partOf']).to be_blank
end 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 context 'when account is permanently suspended' do
before do before do
alice.suspend! alice.suspend!

+ 18
- 1
spec/controllers/following_accounts_controller_spec.rb View File

@ -3,7 +3,7 @@ require 'rails_helper'
describe FollowingAccountsController do describe FollowingAccountsController do
render_views render_views
let(:alice) { Fabricate(:account, username: 'alice') }
let(:alice) { Fabricate(:user).account }
let(:followee0) { Fabricate(:account) } let(:followee0) { Fabricate(:account) }
let(:followee1) { Fabricate(:account) } let(:followee1) { Fabricate(:account) }
@ -101,6 +101,23 @@ describe FollowingAccountsController do
expect(body['partOf']).to be_blank expect(body['partOf']).to be_blank
end 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 context 'when account is permanently suspended' do
before do before do
alice.suspend! alice.suspend!

Loading…
Cancel
Save