|
|
@ -195,11 +195,11 @@ RSpec.describe FeedManager do |
|
|
|
account = Fabricate(:account) |
|
|
|
status = Fabricate(:status) |
|
|
|
members = FeedManager::MAX_ITEMS.times.map { |count| [count, count] } |
|
|
|
Redis.current.zadd("feed:home:#{account.id}", members) |
|
|
|
redis.zadd("feed:home:#{account.id}", members) |
|
|
|
|
|
|
|
FeedManager.instance.push_to_home(account, status) |
|
|
|
|
|
|
|
expect(Redis.current.zcard("feed:home:#{account.id}")).to eq FeedManager::MAX_ITEMS |
|
|
|
expect(redis.zcard("feed:home:#{account.id}")).to eq FeedManager::MAX_ITEMS |
|
|
|
end |
|
|
|
|
|
|
|
context 'reblogs' do |
|
|
@ -424,7 +424,7 @@ RSpec.describe FeedManager do |
|
|
|
|
|
|
|
FeedManager.instance.merge_into_home(account, reblog.account) |
|
|
|
|
|
|
|
expect(Redis.current.zscore("feed:home:0", reblog.id)).to eq nil |
|
|
|
expect(redis.zscore("feed:home:0", reblog.id)).to eq nil |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
@ -440,13 +440,13 @@ RSpec.describe FeedManager do |
|
|
|
FeedManager.instance.push_to_home(receiver, status) |
|
|
|
|
|
|
|
# The reblogging status should show up under normal conditions. |
|
|
|
expect(Redis.current.zrange("feed:home:#{receiver.id}", 0, -1)).to include(status.id.to_s) |
|
|
|
expect(redis.zrange("feed:home:#{receiver.id}", 0, -1)).to include(status.id.to_s) |
|
|
|
|
|
|
|
FeedManager.instance.unpush_from_home(receiver, status) |
|
|
|
|
|
|
|
# Restore original status |
|
|
|
expect(Redis.current.zrange("feed:home:#{receiver.id}", 0, -1)).to_not include(status.id.to_s) |
|
|
|
expect(Redis.current.zrange("feed:home:#{receiver.id}", 0, -1)).to include(reblogged.id.to_s) |
|
|
|
expect(redis.zrange("feed:home:#{receiver.id}", 0, -1)).to_not include(status.id.to_s) |
|
|
|
expect(redis.zrange("feed:home:#{receiver.id}", 0, -1)).to include(reblogged.id.to_s) |
|
|
|
end |
|
|
|
|
|
|
|
it 'removes a reblogged status if it was only reblogged once' do |
|
|
@ -456,11 +456,11 @@ RSpec.describe FeedManager do |
|
|
|
FeedManager.instance.push_to_home(receiver, status) |
|
|
|
|
|
|
|
# The reblogging status should show up under normal conditions. |
|
|
|
expect(Redis.current.zrange("feed:home:#{receiver.id}", 0, -1)).to eq [status.id.to_s] |
|
|
|
expect(redis.zrange("feed:home:#{receiver.id}", 0, -1)).to eq [status.id.to_s] |
|
|
|
|
|
|
|
FeedManager.instance.unpush_from_home(receiver, status) |
|
|
|
|
|
|
|
expect(Redis.current.zrange("feed:home:#{receiver.id}", 0, -1)).to be_empty |
|
|
|
expect(redis.zrange("feed:home:#{receiver.id}", 0, -1)).to be_empty |
|
|
|
end |
|
|
|
|
|
|
|
it 'leaves a multiply-reblogged status if another reblog was in feed' do |
|
|
@ -472,13 +472,13 @@ RSpec.describe FeedManager do |
|
|
|
end |
|
|
|
|
|
|
|
# The reblogging status should show up under normal conditions. |
|
|
|
expect(Redis.current.zrange("feed:home:#{receiver.id}", 0, -1)).to eq [reblogs.first.id.to_s] |
|
|
|
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) |
|
|
|
end |
|
|
|
|
|
|
|
expect(Redis.current.zrange("feed:home:#{receiver.id}", 0, -1)).to eq [reblogs.last.id.to_s] |
|
|
|
expect(redis.zrange("feed:home:#{receiver.id}", 0, -1)).to eq [reblogs.last.id.to_s] |
|
|
|
end |
|
|
|
|
|
|
|
it 'sends push updates' do |
|
|
@ -486,11 +486,11 @@ RSpec.describe FeedManager do |
|
|
|
|
|
|
|
FeedManager.instance.push_to_home(receiver, status) |
|
|
|
|
|
|
|
allow(Redis.current).to receive_messages(publish: nil) |
|
|
|
allow(redis).to receive_messages(publish: nil) |
|
|
|
FeedManager.instance.unpush_from_home(receiver, status) |
|
|
|
|
|
|
|
deletion = Oj.dump(event: :delete, payload: status.id.to_s) |
|
|
|
expect(Redis.current).to have_received(:publish).with("timeline:#{receiver.id}", deletion) |
|
|
|
expect(redis).to have_received(:publish).with("timeline:#{receiver.id}", deletion) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
@ -508,14 +508,14 @@ RSpec.describe FeedManager do |
|
|
|
|
|
|
|
before do |
|
|
|
[status_1, status_3, status_5, status_6, status_7].each do |status| |
|
|
|
Redis.current.zadd("feed:home:#{account.id}", status.id, status.id) |
|
|
|
redis.zadd("feed:home:#{account.id}", status.id, status.id) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
it 'correctly cleans the home timeline' do |
|
|
|
FeedManager.instance.clear_from_home(account, target_account) |
|
|
|
|
|
|
|
expect(Redis.current.zrange("feed:home:#{account.id}", 0, -1)).to eq [status_1.id.to_s, status_7.id.to_s] |
|
|
|
expect(redis.zrange("feed:home:#{account.id}", 0, -1)).to eq [status_1.id.to_s, status_7.id.to_s] |
|
|
|
end |
|
|
|
end |
|
|
|
end |