2017-06-14 12:01:35 -04:00
|
|
|
require 'rails_helper'
|
|
|
|
|
2018-05-02 12:58:48 -04:00
|
|
|
RSpec.describe BatchedRemoveStatusService, type: :service do
|
2017-06-14 12:01:35 -04:00
|
|
|
subject { BatchedRemoveStatusService.new }
|
|
|
|
|
|
|
|
let!(:alice) { Fabricate(:account) }
|
2021-05-07 13:32:58 -04:00
|
|
|
let!(:bob) { Fabricate(:account, username: 'bob', domain: 'example.com') }
|
2022-01-27 18:46:42 -05:00
|
|
|
let!(:jeff) { Fabricate(:account) }
|
2017-08-12 18:44:41 -04:00
|
|
|
let!(:hank) { Fabricate(:account, username: 'hank', protocol: :activitypub, domain: 'example.com', inbox_url: 'http://example.com/inbox') }
|
2017-06-14 12:01:35 -04:00
|
|
|
|
2019-01-05 06:43:28 -05:00
|
|
|
let(:status1) { PostStatusService.new.call(alice, text: 'Hello @bob@example.com') }
|
|
|
|
let(:status2) { PostStatusService.new.call(alice, text: 'Another status') }
|
2017-06-14 12:01:35 -04:00
|
|
|
|
|
|
|
before do
|
2022-04-28 11:47:34 -04:00
|
|
|
allow(redis).to receive_messages(publish: nil)
|
2017-06-14 12:01:35 -04:00
|
|
|
|
2017-08-12 18:44:41 -04:00
|
|
|
stub_request(:post, 'http://example.com/inbox').to_return(status: 200)
|
2017-06-14 12:01:35 -04:00
|
|
|
|
2018-10-07 22:50:11 -04:00
|
|
|
jeff.user.update(current_sign_in_at: Time.zone.now)
|
2017-06-14 12:01:35 -04:00
|
|
|
jeff.follow!(alice)
|
2017-08-12 18:44:41 -04:00
|
|
|
hank.follow!(alice)
|
2017-06-14 12:01:35 -04:00
|
|
|
|
|
|
|
status1
|
|
|
|
status2
|
|
|
|
|
|
|
|
subject.call([status1, status2])
|
|
|
|
end
|
|
|
|
|
2020-12-22 11:13:55 -05:00
|
|
|
it 'removes statuses' do
|
|
|
|
expect { Status.find(status1.id) }.to raise_error ActiveRecord::RecordNotFound
|
|
|
|
expect { Status.find(status2.id) }.to raise_error ActiveRecord::RecordNotFound
|
|
|
|
end
|
|
|
|
|
2017-06-14 12:01:35 -04:00
|
|
|
it 'removes statuses from author\'s home feed' do
|
2017-11-17 18:16:48 -05:00
|
|
|
expect(HomeFeed.new(alice).get(10)).to_not include([status1.id, status2.id])
|
2017-06-14 12:01:35 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'removes statuses from local follower\'s home feed' do
|
2017-11-17 18:16:48 -05:00
|
|
|
expect(HomeFeed.new(jeff).get(10)).to_not include([status1.id, status2.id])
|
2017-06-14 12:01:35 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'notifies streaming API of followers' do
|
2022-04-28 11:47:34 -04:00
|
|
|
expect(redis).to have_received(:publish).with("timeline:#{jeff.id}", any_args).at_least(:once)
|
2017-06-14 12:01:35 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'notifies streaming API of public timeline' do
|
2022-04-28 11:47:34 -04:00
|
|
|
expect(redis).to have_received(:publish).with('timeline:public', any_args).at_least(:once)
|
2017-06-14 12:01:35 -04:00
|
|
|
end
|
|
|
|
|
2017-08-12 18:44:41 -04:00
|
|
|
it 'sends delete activity to followers' do
|
|
|
|
expect(a_request(:post, 'http://example.com/inbox')).to have_been_made.at_least_once
|
|
|
|
end
|
2017-06-14 12:01:35 -04:00
|
|
|
end
|