diff options
author | David Yip <yipdw@member.fsf.org> | 2017-10-16 15:46:12 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-16 15:46:12 -0500 |
commit | 7c44ad63550ccf3cb7532440f79196b20dc24c5d (patch) | |
tree | fb5d8ed08dc130607fd7fd31c67b7cad4ebfd8f5 /spec/lib | |
parent | 6cd5b3bbe5a11fcf25bbefba2803f2ae840f39fc (diff) | |
parent | 37ff061d9bf0a91da6580960be01e3c6bc5e5c4c (diff) |
Merge pull request #181 from glitch-soc/upstream-merge-again
Merge upstream, pull in fixes for tootsuite/mastodon#{5409,5417}
Diffstat (limited to 'spec/lib')
-rw-r--r-- | spec/lib/feed_manager_spec.rb | 61 |
1 files changed, 47 insertions, 14 deletions
diff --git a/spec/lib/feed_manager_spec.rb b/spec/lib/feed_manager_spec.rb index 923894ccb..454c3afec 100644 --- a/spec/lib/feed_manager_spec.rb +++ b/spec/lib/feed_manager_spec.rb @@ -231,33 +231,66 @@ RSpec.describe FeedManager do end describe '#unpush' do - it 'leaves a reblogged status when deleting the reblog' do - account = Fabricate(:account) + let(:receiver) { Fabricate(:account) } + + it 'leaves a reblogged status if original was on feed' do reblogged = Fabricate(:status) - status = Fabricate(:status, reblog: reblogged) + status = Fabricate(:status, reblog: reblogged) - FeedManager.instance.push('type', account, status) + FeedManager.instance.push('type', receiver, reblogged) + FeedManager::REBLOG_FALLOFF.times { FeedManager.instance.push('type', receiver, Fabricate(:status)) } + FeedManager.instance.push('type', receiver, status) + + # The reblogging status should show up under normal conditions. + expect(Redis.current.zrange("feed:type:#{receiver.id}", 0, -1)).to include(status.id.to_s) + + FeedManager.instance.unpush('type', receiver, status) + + # Restore original status + expect(Redis.current.zrange("feed:type:#{receiver.id}", 0, -1)).to_not include(status.id.to_s) + expect(Redis.current.zrange("feed:type:#{receiver.id}", 0, -1)).to include(reblogged.id.to_s) + end + + it 'removes a reblogged status if it was only reblogged once' do + reblogged = Fabricate(:status) + status = Fabricate(:status, reblog: reblogged) + + FeedManager.instance.push('type', receiver, status) # The reblogging status should show up under normal conditions. - expect(Redis.current.zrange("feed:type:#{account.id}", 0, -1)).to eq [status.id.to_s] + expect(Redis.current.zrange("feed:type:#{receiver.id}", 0, -1)).to eq [status.id.to_s] - FeedManager.instance.unpush('type', account, status) + FeedManager.instance.unpush('type', receiver, status) - # Because we couldn't tell if the status showed up any other way, - # we had to stick the reblogged status in by itself. - expect(Redis.current.zrange("feed:type:#{account.id}", 0, -1)).to eq [reblogged.id.to_s] + expect(Redis.current.zrange("feed:type:#{receiver.id}", 0, -1)).to be_empty + end + + it 'leaves a reblogged status if another reblog was in feed' do + reblogged = Fabricate(:status) + status = Fabricate(:status, reblog: reblogged) + another_status = Fabricate(:status, reblog: reblogged) + + FeedManager.instance.push('type', receiver, status) + FeedManager.instance.push('type', receiver, another_status) + + # The reblogging status should show up under normal conditions. + expect(Redis.current.zrange("feed:type:#{receiver.id}", 0, -1)).to eq [status.id.to_s] + + FeedManager.instance.unpush('type', receiver, status) + + expect(Redis.current.zrange("feed:type:#{receiver.id}", 0, -1)).to eq [another_status.id.to_s] end it 'sends push updates' do - account = Fabricate(:account) - status = Fabricate(:status) - FeedManager.instance.push('type', account, status) + status = Fabricate(:status) + + FeedManager.instance.push('type', receiver, status) allow(Redis.current).to receive_messages(publish: nil) - FeedManager.instance.unpush('type', account, status) + FeedManager.instance.unpush('type', receiver, status) deletion = Oj.dump(event: :delete, payload: status.id.to_s) - expect(Redis.current).to have_received(:publish).with("timeline:#{account.id}", deletion) + expect(Redis.current).to have_received(:publish).with("timeline:#{receiver.id}", deletion) end end end |