|
|
|
@ -15,7 +15,7 @@ RSpec.describe FeedManager do
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
describe '#key' do
|
|
|
|
|
subject { FeedManager.instance.key(:home, 1) }
|
|
|
|
|
subject { described_class.instance.key(:home, 1) }
|
|
|
|
|
|
|
|
|
|
it 'returns a string' do
|
|
|
|
|
expect(subject).to be_a String
|
|
|
|
@ -32,26 +32,26 @@ RSpec.describe FeedManager do
|
|
|
|
|
it 'returns false for followee\'s status' do
|
|
|
|
|
status = Fabricate(:status, text: 'Hello world', account: alice)
|
|
|
|
|
bob.follow!(alice)
|
|
|
|
|
expect(FeedManager.instance.filter?(:home, status, bob)).to be false
|
|
|
|
|
expect(described_class.instance.filter?(:home, status, bob)).to be false
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'returns false for reblog by followee' do
|
|
|
|
|
status = Fabricate(:status, text: 'Hello world', account: jeff)
|
|
|
|
|
reblog = Fabricate(:status, reblog: status, account: alice)
|
|
|
|
|
bob.follow!(alice)
|
|
|
|
|
expect(FeedManager.instance.filter?(:home, reblog, bob)).to be false
|
|
|
|
|
expect(described_class.instance.filter?(:home, reblog, bob)).to be false
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'returns true for post from account who blocked me' do
|
|
|
|
|
status = Fabricate(:status, text: 'Hello, World', account: alice)
|
|
|
|
|
alice.block!(bob)
|
|
|
|
|
expect(FeedManager.instance.filter?(:home, status, bob)).to be true
|
|
|
|
|
expect(described_class.instance.filter?(:home, status, bob)).to be true
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'returns true for post from blocked account' do
|
|
|
|
|
status = Fabricate(:status, text: 'Hello, World', account: alice)
|
|
|
|
|
bob.block!(alice)
|
|
|
|
|
expect(FeedManager.instance.filter?(:home, status, bob)).to be true
|
|
|
|
|
expect(described_class.instance.filter?(:home, status, bob)).to be true
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'returns true for reblog by followee of blocked account' do
|
|
|
|
@ -59,7 +59,7 @@ RSpec.describe FeedManager do
|
|
|
|
|
reblog = Fabricate(:status, reblog: status, account: alice)
|
|
|
|
|
bob.follow!(alice)
|
|
|
|
|
bob.block!(jeff)
|
|
|
|
|
expect(FeedManager.instance.filter?(:home, reblog, bob)).to be true
|
|
|
|
|
expect(described_class.instance.filter?(:home, reblog, bob)).to be true
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'returns true for reblog by followee of muted account' do
|
|
|
|
@ -67,7 +67,7 @@ RSpec.describe FeedManager do
|
|
|
|
|
reblog = Fabricate(:status, reblog: status, account: alice)
|
|
|
|
|
bob.follow!(alice)
|
|
|
|
|
bob.mute!(jeff)
|
|
|
|
|
expect(FeedManager.instance.filter?(:home, reblog, bob)).to be true
|
|
|
|
|
expect(described_class.instance.filter?(:home, reblog, bob)).to be true
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'returns true for reblog by followee of someone who is blocking recipient' do
|
|
|
|
@ -75,14 +75,14 @@ RSpec.describe FeedManager do
|
|
|
|
|
reblog = Fabricate(:status, reblog: status, account: alice)
|
|
|
|
|
bob.follow!(alice)
|
|
|
|
|
jeff.block!(bob)
|
|
|
|
|
expect(FeedManager.instance.filter?(:home, reblog, bob)).to be true
|
|
|
|
|
expect(described_class.instance.filter?(:home, reblog, bob)).to be true
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'returns true for reblog from account with reblogs disabled' do
|
|
|
|
|
status = Fabricate(:status, text: 'Hello world', account: jeff)
|
|
|
|
|
reblog = Fabricate(:status, reblog: status, account: alice)
|
|
|
|
|
bob.follow!(alice, reblogs: false)
|
|
|
|
|
expect(FeedManager.instance.filter?(:home, reblog, bob)).to be true
|
|
|
|
|
expect(described_class.instance.filter?(:home, reblog, bob)).to be true
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'returns false for reply by followee to another followee' do
|
|
|
|
@ -90,49 +90,49 @@ RSpec.describe FeedManager do
|
|
|
|
|
reply = Fabricate(:status, text: 'Nay', thread: status, account: alice)
|
|
|
|
|
bob.follow!(alice)
|
|
|
|
|
bob.follow!(jeff)
|
|
|
|
|
expect(FeedManager.instance.filter?(:home, reply, bob)).to be false
|
|
|
|
|
expect(described_class.instance.filter?(:home, reply, bob)).to be false
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'returns false for reply by followee to recipient' do
|
|
|
|
|
status = Fabricate(:status, text: 'Hello world', account: bob)
|
|
|
|
|
reply = Fabricate(:status, text: 'Nay', thread: status, account: alice)
|
|
|
|
|
bob.follow!(alice)
|
|
|
|
|
expect(FeedManager.instance.filter?(:home, reply, bob)).to be false
|
|
|
|
|
expect(described_class.instance.filter?(:home, reply, bob)).to be false
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'returns false for reply by followee to self' do
|
|
|
|
|
status = Fabricate(:status, text: 'Hello world', account: alice)
|
|
|
|
|
reply = Fabricate(:status, text: 'Nay', thread: status, account: alice)
|
|
|
|
|
bob.follow!(alice)
|
|
|
|
|
expect(FeedManager.instance.filter?(:home, reply, bob)).to be false
|
|
|
|
|
expect(described_class.instance.filter?(:home, reply, bob)).to be false
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'returns true for reply by followee to non-followed account' do
|
|
|
|
|
status = Fabricate(:status, text: 'Hello world', account: jeff)
|
|
|
|
|
reply = Fabricate(:status, text: 'Nay', thread: status, account: alice)
|
|
|
|
|
bob.follow!(alice)
|
|
|
|
|
expect(FeedManager.instance.filter?(:home, reply, bob)).to be true
|
|
|
|
|
expect(described_class.instance.filter?(:home, reply, bob)).to be true
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'returns true for the second reply by followee to a non-federated status' do
|
|
|
|
|
reply = Fabricate(:status, text: 'Reply 1', reply: true, account: alice)
|
|
|
|
|
second_reply = Fabricate(:status, text: 'Reply 2', thread: reply, account: alice)
|
|
|
|
|
bob.follow!(alice)
|
|
|
|
|
expect(FeedManager.instance.filter?(:home, second_reply, bob)).to be true
|
|
|
|
|
expect(described_class.instance.filter?(:home, second_reply, bob)).to be true
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'returns false for status by followee mentioning another account' do
|
|
|
|
|
bob.follow!(alice)
|
|
|
|
|
jeff.follow!(alice)
|
|
|
|
|
status = PostStatusService.new.call(alice, text: 'Hey @jeff')
|
|
|
|
|
expect(FeedManager.instance.filter?(:home, status, bob)).to be false
|
|
|
|
|
expect(described_class.instance.filter?(:home, status, bob)).to be false
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'returns true for status by followee mentioning blocked account' do
|
|
|
|
|
bob.block!(jeff)
|
|
|
|
|
bob.follow!(alice)
|
|
|
|
|
status = PostStatusService.new.call(alice, text: 'Hey @jeff')
|
|
|
|
|
expect(FeedManager.instance.filter?(:home, status, bob)).to be true
|
|
|
|
|
expect(described_class.instance.filter?(:home, status, bob)).to be true
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'returns true for reblog of a personally blocked domain' do
|
|
|
|
@ -140,19 +140,19 @@ RSpec.describe FeedManager do
|
|
|
|
|
alice.follow!(jeff)
|
|
|
|
|
status = Fabricate(:status, text: 'Hello world', account: bob)
|
|
|
|
|
reblog = Fabricate(:status, reblog: status, account: jeff)
|
|
|
|
|
expect(FeedManager.instance.filter?(:home, reblog, alice)).to be true
|
|
|
|
|
expect(described_class.instance.filter?(:home, reblog, alice)).to be true
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'returns true for German post when follow is set to English only' do
|
|
|
|
|
alice.follow!(bob, languages: %w(en))
|
|
|
|
|
status = Fabricate(:status, text: 'Hallo Welt', account: bob, language: 'de')
|
|
|
|
|
expect(FeedManager.instance.filter?(:home, status, alice)).to be true
|
|
|
|
|
expect(described_class.instance.filter?(:home, status, alice)).to be true
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'returns false for German post when follow is set to German' do
|
|
|
|
|
alice.follow!(bob, languages: %w(de))
|
|
|
|
|
status = Fabricate(:status, text: 'Hallo Welt', account: bob, language: 'de')
|
|
|
|
|
expect(FeedManager.instance.filter?(:home, status, alice)).to be false
|
|
|
|
|
expect(described_class.instance.filter?(:home, status, alice)).to be false
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'returns true for post from followee on exclusive list' do
|
|
|
|
@ -196,27 +196,27 @@ RSpec.describe FeedManager do
|
|
|
|
|
it 'returns true for status that mentions blocked account' do
|
|
|
|
|
bob.block!(jeff)
|
|
|
|
|
status = PostStatusService.new.call(alice, text: 'Hey @jeff')
|
|
|
|
|
expect(FeedManager.instance.filter?(:mentions, status, bob)).to be true
|
|
|
|
|
expect(described_class.instance.filter?(:mentions, status, bob)).to be true
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'returns true for status that replies to a blocked account' do
|
|
|
|
|
status = Fabricate(:status, text: 'Hello world', account: jeff)
|
|
|
|
|
reply = Fabricate(:status, text: 'Nay', thread: status, account: alice)
|
|
|
|
|
bob.block!(jeff)
|
|
|
|
|
expect(FeedManager.instance.filter?(:mentions, reply, bob)).to be true
|
|
|
|
|
expect(described_class.instance.filter?(:mentions, reply, bob)).to be true
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'returns true for status by silenced account who recipient is not following' do
|
|
|
|
|
status = Fabricate(:status, text: 'Hello world', account: alice)
|
|
|
|
|
alice.silence!
|
|
|
|
|
expect(FeedManager.instance.filter?(:mentions, status, bob)).to be true
|
|
|
|
|
expect(described_class.instance.filter?(:mentions, status, bob)).to be true
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'returns false for status by followed silenced account' do
|
|
|
|
|
status = Fabricate(:status, text: 'Hello world', account: alice)
|
|
|
|
|
alice.silence!
|
|
|
|
|
bob.follow!(alice)
|
|
|
|
|
expect(FeedManager.instance.filter?(:mentions, status, bob)).to be false
|
|
|
|
|
expect(described_class.instance.filter?(:mentions, status, bob)).to be false
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
@ -228,7 +228,7 @@ RSpec.describe FeedManager do
|
|
|
|
|
members = Array.new(FeedManager::MAX_ITEMS) { |count| [count, count] }
|
|
|
|
|
redis.zadd("feed:home:#{account.id}", members)
|
|
|
|
|
|
|
|
|
|
FeedManager.instance.push_to_home(account, status)
|
|
|
|
|
described_class.instance.push_to_home(account, status)
|
|
|
|
|
|
|
|
|
|
expect(redis.zcard("feed:home:#{account.id}")).to eq FeedManager::MAX_ITEMS
|
|
|
|
|
end
|
|
|
|
@ -239,7 +239,7 @@ RSpec.describe FeedManager do
|
|
|
|
|
reblogged = Fabricate(:status)
|
|
|
|
|
reblog = Fabricate(:status, reblog: reblogged)
|
|
|
|
|
|
|
|
|
|
expect(FeedManager.instance.push_to_home(account, reblog)).to be true
|
|
|
|
|
expect(described_class.instance.push_to_home(account, reblog)).to be true
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'does not save a new reblog of a recent status' do
|
|
|
|
@ -247,9 +247,9 @@ RSpec.describe FeedManager do
|
|
|
|
|
reblogged = Fabricate(:status)
|
|
|
|
|
reblog = Fabricate(:status, reblog: reblogged)
|
|
|
|
|
|
|
|
|
|
FeedManager.instance.push_to_home(account, reblogged)
|
|
|
|
|
described_class.instance.push_to_home(account, reblogged)
|
|
|
|
|
|
|
|
|
|
expect(FeedManager.instance.push_to_home(account, reblog)).to be false
|
|
|
|
|
expect(described_class.instance.push_to_home(account, reblog)).to be false
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'saves a new reblog of an old status' do
|
|
|
|
@ -257,14 +257,14 @@ RSpec.describe FeedManager do
|
|
|
|
|
reblogged = Fabricate(:status)
|
|
|
|
|
reblog = Fabricate(:status, reblog: reblogged)
|
|
|
|
|
|
|
|
|
|
FeedManager.instance.push_to_home(account, reblogged)
|
|
|
|
|
described_class.instance.push_to_home(account, reblogged)
|
|
|
|
|
|
|
|
|
|
# Fill the feed with intervening statuses
|
|
|
|
|
FeedManager::REBLOG_FALLOFF.times do
|
|
|
|
|
FeedManager.instance.push_to_home(account, Fabricate(:status))
|
|
|
|
|
described_class.instance.push_to_home(account, Fabricate(:status))
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
expect(FeedManager.instance.push_to_home(account, reblog)).to be true
|
|
|
|
|
expect(described_class.instance.push_to_home(account, reblog)).to be true
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'does not save a new reblog of a recently-reblogged status' do
|
|
|
|
@ -273,10 +273,10 @@ RSpec.describe FeedManager do
|
|
|
|
|
reblogs = Array.new(2) { Fabricate(:status, reblog: reblogged) }
|
|
|
|
|
|
|
|
|
|
# The first reblog will be accepted
|
|
|
|
|
FeedManager.instance.push_to_home(account, reblogs.first)
|
|
|
|
|
described_class.instance.push_to_home(account, reblogs.first)
|
|
|
|
|
|
|
|
|
|
# The second reblog should be ignored
|
|
|
|
|
expect(FeedManager.instance.push_to_home(account, reblogs.last)).to be false
|
|
|
|
|
expect(described_class.instance.push_to_home(account, reblogs.last)).to be false
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'saves a new reblog of a recently-reblogged status when previous reblog has been deleted' do
|
|
|
|
@ -285,15 +285,15 @@ RSpec.describe FeedManager do
|
|
|
|
|
old_reblog = Fabricate(:status, reblog: reblogged)
|
|
|
|
|
|
|
|
|
|
# The first reblog should be accepted
|
|
|
|
|
expect(FeedManager.instance.push_to_home(account, old_reblog)).to be true
|
|
|
|
|
expect(described_class.instance.push_to_home(account, old_reblog)).to be true
|
|
|
|
|
|
|
|
|
|
# The first reblog should be successfully removed
|
|
|
|
|
expect(FeedManager.instance.unpush_from_home(account, old_reblog)).to be true
|
|
|
|
|
expect(described_class.instance.unpush_from_home(account, old_reblog)).to be true
|
|
|
|
|
|
|
|
|
|
reblog = Fabricate(:status, reblog: reblogged)
|
|
|
|
|
|
|
|
|
|
# The second reblog should be accepted
|
|
|
|
|
expect(FeedManager.instance.push_to_home(account, reblog)).to be true
|
|
|
|
|
expect(described_class.instance.push_to_home(account, reblog)).to be true
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'does not save a new reblog of a multiply-reblogged-then-unreblogged status' do
|
|
|
|
@ -302,14 +302,14 @@ RSpec.describe FeedManager do
|
|
|
|
|
reblogs = Array.new(3) { Fabricate(:status, reblog: reblogged) }
|
|
|
|
|
|
|
|
|
|
# Accept the reblogs
|
|
|
|
|
FeedManager.instance.push_to_home(account, reblogs[0])
|
|
|
|
|
FeedManager.instance.push_to_home(account, reblogs[1])
|
|
|
|
|
described_class.instance.push_to_home(account, reblogs[0])
|
|
|
|
|
described_class.instance.push_to_home(account, reblogs[1])
|
|
|
|
|
|
|
|
|
|
# Unreblog the first one
|
|
|
|
|
FeedManager.instance.unpush_from_home(account, reblogs[0])
|
|
|
|
|
described_class.instance.unpush_from_home(account, reblogs[0])
|
|
|
|
|
|
|
|
|
|
# The last reblog should still be ignored
|
|
|
|
|
expect(FeedManager.instance.push_to_home(account, reblogs.last)).to be false
|
|
|
|
|
expect(described_class.instance.push_to_home(account, reblogs.last)).to be false
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'saves a new reblog of a long-ago-reblogged status' do
|
|
|
|
@ -318,15 +318,15 @@ RSpec.describe FeedManager do
|
|
|
|
|
reblogs = Array.new(2) { Fabricate(:status, reblog: reblogged) }
|
|
|
|
|
|
|
|
|
|
# The first reblog will be accepted
|
|
|
|
|
FeedManager.instance.push_to_home(account, reblogs.first)
|
|
|
|
|
described_class.instance.push_to_home(account, reblogs.first)
|
|
|
|
|
|
|
|
|
|
# Fill the feed with intervening statuses
|
|
|
|
|
FeedManager::REBLOG_FALLOFF.times do
|
|
|
|
|
FeedManager.instance.push_to_home(account, Fabricate(:status))
|
|
|
|
|
described_class.instance.push_to_home(account, Fabricate(:status))
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# The second reblog should also be accepted
|
|
|
|
|
expect(FeedManager.instance.push_to_home(account, reblogs.last)).to be true
|
|
|
|
|
expect(described_class.instance.push_to_home(account, reblogs.last)).to be true
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
@ -334,9 +334,9 @@ RSpec.describe FeedManager do
|
|
|
|
|
account = Fabricate(:account)
|
|
|
|
|
reblog = Fabricate(:status)
|
|
|
|
|
status = Fabricate(:status, reblog: reblog)
|
|
|
|
|
FeedManager.instance.push_to_home(account, status)
|
|
|
|
|
described_class.instance.push_to_home(account, status)
|
|
|
|
|
|
|
|
|
|
expect(FeedManager.instance.push_to_home(account, reblog)).to be false
|
|
|
|
|
expect(described_class.instance.push_to_home(account, reblog)).to be false
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
@ -359,9 +359,9 @@ RSpec.describe FeedManager do
|
|
|
|
|
it "does not push when the given status's reblog is already inserted" do
|
|
|
|
|
reblog = Fabricate(:status)
|
|
|
|
|
status = Fabricate(:status, reblog: reblog)
|
|
|
|
|
FeedManager.instance.push_to_list(list, status)
|
|
|
|
|
described_class.instance.push_to_list(list, status)
|
|
|
|
|
|
|
|
|
|
expect(FeedManager.instance.push_to_list(list, reblog)).to be false
|
|
|
|
|
expect(described_class.instance.push_to_list(list, reblog)).to be false
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context 'when replies policy is set to no replies' do
|
|
|
|
@ -371,19 +371,19 @@ RSpec.describe FeedManager do
|
|
|
|
|
|
|
|
|
|
it 'pushes statuses that are not replies' do
|
|
|
|
|
status = Fabricate(:status, text: 'Hello world', account: bob)
|
|
|
|
|
expect(FeedManager.instance.push_to_list(list, status)).to be true
|
|
|
|
|
expect(described_class.instance.push_to_list(list, status)).to be true
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'pushes statuses that are replies to list owner' do
|
|
|
|
|
status = Fabricate(:status, text: 'Hello world', account: owner)
|
|
|
|
|
reply = Fabricate(:status, text: 'Nay', thread: status, account: bob)
|
|
|
|
|
expect(FeedManager.instance.push_to_list(list, reply)).to be true
|
|
|
|
|
expect(described_class.instance.push_to_list(list, reply)).to be true
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'does not push replies to another member of the list' do
|
|
|
|
|
status = Fabricate(:status, text: 'Hello world', account: alice)
|
|
|
|
|
reply = Fabricate(:status, text: 'Nay', thread: status, account: bob)
|
|
|
|
|
expect(FeedManager.instance.push_to_list(list, reply)).to be false
|
|
|
|
|
expect(described_class.instance.push_to_list(list, reply)).to be false
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
@ -394,25 +394,25 @@ RSpec.describe FeedManager do
|
|
|
|
|
|
|
|
|
|
it 'pushes statuses that are not replies' do
|
|
|
|
|
status = Fabricate(:status, text: 'Hello world', account: bob)
|
|
|
|
|
expect(FeedManager.instance.push_to_list(list, status)).to be true
|
|
|
|
|
expect(described_class.instance.push_to_list(list, status)).to be true
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'pushes statuses that are replies to list owner' do
|
|
|
|
|
status = Fabricate(:status, text: 'Hello world', account: owner)
|
|
|
|
|
reply = Fabricate(:status, text: 'Nay', thread: status, account: bob)
|
|
|
|
|
expect(FeedManager.instance.push_to_list(list, reply)).to be true
|
|
|
|
|
expect(described_class.instance.push_to_list(list, reply)).to be true
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'pushes replies to another member of the list' do
|
|
|
|
|
status = Fabricate(:status, text: 'Hello world', account: alice)
|
|
|
|
|
reply = Fabricate(:status, text: 'Nay', thread: status, account: bob)
|
|
|
|
|
expect(FeedManager.instance.push_to_list(list, reply)).to be true
|
|
|
|
|
expect(described_class.instance.push_to_list(list, reply)).to be true
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'does not push replies to someone not a member of the list' do
|
|
|
|
|
status = Fabricate(:status, text: 'Hello world', account: eve)
|
|
|
|
|
reply = Fabricate(:status, text: 'Nay', thread: status, account: bob)
|
|
|
|
|
expect(FeedManager.instance.push_to_list(list, reply)).to be false
|
|
|
|
|
expect(described_class.instance.push_to_list(list, reply)).to be false
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
@ -423,25 +423,25 @@ RSpec.describe FeedManager do
|
|
|
|
|
|
|
|
|
|
it 'pushes statuses that are not replies' do
|
|
|
|
|
status = Fabricate(:status, text: 'Hello world', account: bob)
|
|
|
|
|
expect(FeedManager.instance.push_to_list(list, status)).to be true
|
|
|
|
|
expect(described_class.instance.push_to_list(list, status)).to be true
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'pushes statuses that are replies to list owner' do
|
|
|
|
|
status = Fabricate(:status, text: 'Hello world', account: owner)
|
|
|
|
|
reply = Fabricate(:status, text: 'Nay', thread: status, account: bob)
|
|
|
|
|
expect(FeedManager.instance.push_to_list(list, reply)).to be true
|
|
|
|
|
expect(described_class.instance.push_to_list(list, reply)).to be true
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'pushes replies to another member of the list' do
|
|
|
|
|
status = Fabricate(:status, text: 'Hello world', account: alice)
|
|
|
|
|
reply = Fabricate(:status, text: 'Nay', thread: status, account: bob)
|
|
|
|
|
expect(FeedManager.instance.push_to_list(list, reply)).to be true
|
|
|
|
|
expect(described_class.instance.push_to_list(list, reply)).to be true
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'pushes replies to someone not a member of the list' do
|
|
|
|
|
status = Fabricate(:status, text: 'Hello world', account: eve)
|
|
|
|
|
reply = Fabricate(:status, text: 'Nay', thread: status, account: bob)
|
|
|
|
|
expect(FeedManager.instance.push_to_list(list, reply)).to be true
|
|
|
|
|
expect(described_class.instance.push_to_list(list, reply)).to be true
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
@ -451,9 +451,9 @@ RSpec.describe FeedManager do
|
|
|
|
|
account = Fabricate(:account, id: 0)
|
|
|
|
|
reblog = Fabricate(:status)
|
|
|
|
|
status = Fabricate(:status, reblog: reblog)
|
|
|
|
|
FeedManager.instance.push_to_home(account, status)
|
|
|
|
|
described_class.instance.push_to_home(account, status)
|
|
|
|
|
|
|
|
|
|
FeedManager.instance.merge_into_home(account, reblog.account)
|
|
|
|
|
described_class.instance.merge_into_home(account, reblog.account)
|
|
|
|
|
|
|
|
|
|
expect(redis.zscore('feed:home:0', reblog.id)).to be_nil
|
|
|
|
|
end
|
|
|
|
@ -466,14 +466,14 @@ RSpec.describe FeedManager do
|
|
|
|
|
reblogged = Fabricate(:status)
|
|
|
|
|
status = Fabricate(:status, reblog: reblogged)
|
|
|
|
|
|
|
|
|
|
FeedManager.instance.push_to_home(receiver, reblogged)
|
|
|
|
|
FeedManager::REBLOG_FALLOFF.times { FeedManager.instance.push_to_home(receiver, Fabricate(:status)) }
|
|
|
|
|
FeedManager.instance.push_to_home(receiver, status)
|
|
|
|
|
described_class.instance.push_to_home(receiver, reblogged)
|
|
|
|
|
FeedManager::REBLOG_FALLOFF.times { described_class.instance.push_to_home(receiver, Fabricate(:status)) }
|
|
|
|
|
described_class.instance.push_to_home(receiver, status)
|
|
|
|
|
|
|
|
|
|
# The reblogging status should show up under normal conditions.
|
|
|
|
|
expect(redis.zrange("feed:home:#{receiver.id}", 0, -1)).to include(status.id.to_s)
|
|
|
|
|
|
|
|
|
|
FeedManager.instance.unpush_from_home(receiver, status)
|
|
|
|
|
described_class.instance.unpush_from_home(receiver, status)
|
|
|
|
|
|
|
|
|
|
# Restore original status
|
|
|
|
|
expect(redis.zrange("feed:home:#{receiver.id}", 0, -1)).to_not include(status.id.to_s)
|
|
|
|
@ -484,12 +484,12 @@ RSpec.describe FeedManager do
|
|
|
|
|
reblogged = Fabricate(:status)
|
|
|
|
|
status = Fabricate(:status, reblog: reblogged)
|
|
|
|
|
|
|
|
|
|
FeedManager.instance.push_to_home(receiver, status)
|
|
|
|
|
described_class.instance.push_to_home(receiver, status)
|
|
|
|
|
|
|
|
|
|
# The reblogging status should show up under normal conditions.
|
|
|
|
|
expect(redis.zrange("feed:home:#{receiver.id}", 0, -1)).to eq [status.id.to_s]
|
|
|
|
|
|
|
|
|
|
FeedManager.instance.unpush_from_home(receiver, status)
|
|
|
|
|
described_class.instance.unpush_from_home(receiver, status)
|
|
|
|
|
|
|
|
|
|
expect(redis.zrange("feed:home:#{receiver.id}", 0, -1)).to be_empty
|
|
|
|
|
end
|
|
|
|
@ -499,14 +499,14 @@ RSpec.describe FeedManager do
|
|
|
|
|
reblogs = Array.new(3) { Fabricate(:status, reblog: reblogged) }
|
|
|
|
|
|
|
|
|
|
reblogs.each do |reblog|
|
|
|
|
|
FeedManager.instance.push_to_home(receiver, reblog)
|
|
|
|
|
described_class.instance.push_to_home(receiver, reblog)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# The reblogging status should show up under normal conditions.
|
|
|
|
|
expect(redis.zrange("feed:home:#{receiver.id}", 0, -1)).to eq [reblogs.first.id.to_s]
|
|
|
|
|
|
|
|
|
|
reblogs[0...-1].each do |reblog|
|
|
|
|
|
FeedManager.instance.unpush_from_home(receiver, reblog)
|
|
|
|
|
described_class.instance.unpush_from_home(receiver, reblog)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
expect(redis.zrange("feed:home:#{receiver.id}", 0, -1)).to eq [reblogs.last.id.to_s]
|
|
|
|
@ -515,10 +515,10 @@ RSpec.describe FeedManager do
|
|
|
|
|
it 'sends push updates' do
|
|
|
|
|
status = Fabricate(:status)
|
|
|
|
|
|
|
|
|
|
FeedManager.instance.push_to_home(receiver, status)
|
|
|
|
|
described_class.instance.push_to_home(receiver, status)
|
|
|
|
|
|
|
|
|
|
allow(redis).to receive_messages(publish: nil)
|
|
|
|
|
FeedManager.instance.unpush_from_home(receiver, status)
|
|
|
|
|
described_class.instance.unpush_from_home(receiver, status)
|
|
|
|
|
|
|
|
|
|
deletion = Oj.dump(event: :delete, payload: status.id.to_s)
|
|
|
|
|
expect(redis).to have_received(:publish).with("timeline:#{receiver.id}", deletion)
|
|
|
|
@ -544,7 +544,7 @@ RSpec.describe FeedManager do
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'correctly cleans the home timeline' do
|
|
|
|
|
FeedManager.instance.clear_from_home(account, target_account)
|
|
|
|
|
described_class.instance.clear_from_home(account, target_account)
|
|
|
|
|
|
|
|
|
|
expect(redis.zrange("feed:home:#{account.id}", 0, -1)).to eq [status_1.id.to_s, status_7.id.to_s]
|
|
|
|
|
end
|
|
|
|
|