Fix tootctl feeds build
not building list timelines (#33783)
This commit is contained in:
parent
3f4f6317d4
commit
a3d2849d15
5 changed files with 95 additions and 18 deletions
|
@ -7,31 +7,69 @@ RSpec.describe PrecomputeFeedService do
|
|||
|
||||
describe 'call' do
|
||||
let(:account) { Fabricate(:account) }
|
||||
let!(:list) { Fabricate(:list, account: account, exclusive: false) }
|
||||
|
||||
it 'fills a user timeline with statuses' do
|
||||
account = Fabricate(:account)
|
||||
status = Fabricate(:status, account: account)
|
||||
context 'when no eligible status exist' do
|
||||
it 'raises no error and results in an empty timeline' do
|
||||
expect { subject.call(account) }.to_not raise_error
|
||||
|
||||
subject.call(account)
|
||||
|
||||
expect(redis.zscore(FeedManager.instance.key(:home, account.id), status.id)).to be_within(0.1).of(status.id.to_f)
|
||||
expect(redis.zcard(FeedManager.instance.key(:home, account.id))).to eq(0)
|
||||
end
|
||||
end
|
||||
|
||||
it 'does not raise an error even if it could not find any status' do
|
||||
account = Fabricate(:account)
|
||||
expect { subject.call(account) }.to_not raise_error
|
||||
end
|
||||
context 'with eligible statuses' do
|
||||
let(:muted_account) { Fabricate(:account) }
|
||||
let!(:followed_account) { Fabricate(:account) }
|
||||
let!(:requested_account) { Fabricate(:account) }
|
||||
let!(:own_status) { Fabricate(:status, account: account) }
|
||||
let!(:followed_status) { Fabricate(:status, account: followed_account) }
|
||||
let!(:unreadable_dm_from_followed) { Fabricate(:status, account: followed_account, visibility: :direct) }
|
||||
let!(:requested_status) { Fabricate(:status, account: requested_account) }
|
||||
let!(:muted_status) { Fabricate(:status, account: muted_account) }
|
||||
let!(:muted_reblog) { Fabricate(:status, account: followed_account, reblog: muted_status) }
|
||||
let!(:known_reply) { Fabricate(:status, account: followed_account, in_reply_to_id: own_status.id) }
|
||||
let!(:unknown_reply) { Fabricate(:status, account: followed_account, in_reply_to_id: requested_status.id) }
|
||||
|
||||
it 'filters statuses' do
|
||||
account = Fabricate(:account)
|
||||
muted_account = Fabricate(:account)
|
||||
Fabricate(:mute, account: account, target_account: muted_account)
|
||||
reblog = Fabricate(:status, account: muted_account)
|
||||
Fabricate(:status, account: account, reblog: reblog)
|
||||
before do
|
||||
account.follow!(followed_account)
|
||||
account.request_follow!(requested_account)
|
||||
account.mute!(muted_account)
|
||||
|
||||
subject.call(account)
|
||||
AddAccountsToListService.new.call(list, [followed_account])
|
||||
end
|
||||
|
||||
expect(redis.zscore(FeedManager.instance.key(:home, account.id), reblog.id)).to be_nil
|
||||
it "fills a user's home and list timelines with the expected posts" do
|
||||
subject.call(account)
|
||||
|
||||
home_timeline_ids = redis.zrevrangebyscore(FeedManager.instance.key(:home, account.id), '(+inf', '(-inf', limit: [0, 30], with_scores: true).map { |id| id.first.to_i }
|
||||
list_timeline_ids = redis.zrevrangebyscore(FeedManager.instance.key(:list, list.id), '(+inf', '(-inf', limit: [0, 30], with_scores: true).map { |id| id.first.to_i }
|
||||
|
||||
expect(home_timeline_ids).to include(
|
||||
own_status.id,
|
||||
followed_status.id,
|
||||
known_reply.id
|
||||
)
|
||||
|
||||
expect(list_timeline_ids).to include(
|
||||
followed_status.id
|
||||
)
|
||||
|
||||
expect(home_timeline_ids).to_not include(
|
||||
requested_status.id,
|
||||
unknown_reply.id,
|
||||
unreadable_dm_from_followed.id,
|
||||
muted_status.id,
|
||||
muted_reblog.id
|
||||
)
|
||||
|
||||
expect(list_timeline_ids).to_not include(
|
||||
requested_status.id,
|
||||
unknown_reply.id,
|
||||
unreadable_dm_from_followed.id,
|
||||
muted_status.id,
|
||||
muted_reblog.id
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue