mirror of
https://github.com/mastodon/mastodon.git
synced 2025-09-05 09:21:11 +00:00
Add coverage for signed-in-with-blocks scenario on followers/following
This commit is contained in:
parent
25f1a515f8
commit
8caf16b2d4
|
@ -36,15 +36,19 @@ class FollowerAccountsController < ApplicationController
|
|||
def follows
|
||||
return @follows if defined?(@follows)
|
||||
|
||||
scope = Follow.where(target_account: @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)
|
||||
@follows = passive_relationships.recent.page(params[:page]).per(FOLLOW_PER_PAGE).preload(:account)
|
||||
end
|
||||
|
||||
def page_requested?
|
||||
params[:page].present?
|
||||
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)
|
||||
ActivityPub::TagManager.instance.followers_uri_for(@account, page: page) unless page.nil?
|
||||
end
|
||||
|
|
|
@ -39,15 +39,19 @@ class FollowingAccountsController < ApplicationController
|
|||
def follows
|
||||
return @follows if defined?(@follows)
|
||||
|
||||
scope = Follow.where(account: @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)
|
||||
@follows = active_relationships.recent.page(params[:page]).per(FOLLOW_PER_PAGE).preload(:target_account)
|
||||
end
|
||||
|
||||
def page_requested?
|
||||
params[:page].present?
|
||||
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)
|
||||
account_following_index_url(@account, page: page) unless page.nil?
|
||||
end
|
||||
|
|
|
@ -57,6 +57,26 @@ RSpec.describe FollowerAccountsController do
|
|||
)
|
||||
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
|
||||
before do
|
||||
alice.suspend!
|
||||
|
|
|
@ -57,6 +57,26 @@ RSpec.describe FollowingAccountsController do
|
|||
)
|
||||
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
|
||||
before do
|
||||
alice.suspend!
|
||||
|
|
Loading…
Reference in New Issue
Block a user