Compare commits

...

2 Commits

Author SHA1 Message Date
Matt Jankowski
0c2377431c
Merge 8caf16b2d4 into 624c024766 2025-09-03 10:07:12 +00:00
Matt Jankowski
8caf16b2d4 Add coverage for signed-in-with-blocks scenario on followers/following 2025-08-15 08:53:45 -04:00
4 changed files with 54 additions and 6 deletions

View File

@ -36,15 +36,19 @@ class FollowerAccountsController < ApplicationController
def follows def follows
return @follows if defined?(@follows) return @follows if defined?(@follows)
scope = Follow.where(target_account: @account) @follows = passive_relationships.recent.page(params[:page]).per(FOLLOW_PER_PAGE).preload(:account)
scope = scope.where.not(account_id: current_account.excluded_from_timeline_account_ids) if user_signed_in?
@follows = scope.recent.page(params[:page]).per(FOLLOW_PER_PAGE).preload(:account)
end end
def page_requested? def page_requested?
params[:page].present? params[:page].present?
end end
def passive_relationships
@account.passive_relationships.tap do |scope|
scope.merge! scope.where.not(account_id: current_account.excluded_from_timeline_account_ids) if user_signed_in?
end
end
def page_url(page) def page_url(page)
ActivityPub::TagManager.instance.followers_uri_for(@account, page: page) unless page.nil? ActivityPub::TagManager.instance.followers_uri_for(@account, page: page) unless page.nil?
end end

View File

@ -39,15 +39,19 @@ class FollowingAccountsController < ApplicationController
def follows def follows
return @follows if defined?(@follows) return @follows if defined?(@follows)
scope = Follow.where(account: @account) @follows = active_relationships.recent.page(params[:page]).per(FOLLOW_PER_PAGE).preload(:target_account)
scope = scope.where.not(target_account_id: current_account.excluded_from_timeline_account_ids) if user_signed_in?
@follows = scope.recent.page(params[:page]).per(FOLLOW_PER_PAGE).preload(:target_account)
end end
def page_requested? def page_requested?
params[:page].present? params[:page].present?
end end
def active_relationships
@account.active_relationships.tap do |scope|
scope.merge! scope.where.not(target_account_id: current_account.excluded_from_timeline_account_ids) if user_signed_in?
end
end
def page_url(page) def page_url(page)
account_following_index_url(@account, page: page) unless page.nil? account_following_index_url(@account, page: page) unless page.nil?
end end

View File

@ -57,6 +57,26 @@ RSpec.describe FollowerAccountsController do
) )
end end
context 'when request is signed in and user blocks an account' do
let(:account) { Fabricate :account }
before do
Fabricate :block, account:, target_account: follower_bob
sign_in(account.user)
end
it 'returns followers without blocked' do
expect(response)
.to have_http_status(200)
expect(response.parsed_body)
.to include(
orderedItems: contain_exactly(
include(follow_from_chris.account.username)
)
)
end
end
context 'when account is permanently suspended' do context 'when account is permanently suspended' do
before do before do
alice.suspend! alice.suspend!

View File

@ -57,6 +57,26 @@ RSpec.describe FollowingAccountsController do
) )
end end
context 'when request is signed in and user blocks an account' do
let(:account) { Fabricate :account }
before do
Fabricate :block, account:, target_account: followee_bob
sign_in(account.user)
end
it 'returns followers without blocked' do
expect(response)
.to have_http_status(200)
expect(response.parsed_body)
.to include(
orderedItems: contain_exactly(
include(follow_of_chris.target_account.username)
)
)
end
end
context 'when account is permanently suspended' do context 'when account is permanently suspended' do
before do before do
alice.suspend! alice.suspend!