0
0
Fork 0

Reduce factory usage across spec/services area (#32098)

This commit is contained in:
Matt Jankowski 2024-10-04 10:11:15 -04:00 committed by GitHub
parent 4fe7f213a6
commit e4e07b1c34
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
21 changed files with 567 additions and 641 deletions

View file

@ -28,42 +28,38 @@ RSpec.describe RemoveStatusService, :inline_jobs do
Fabricate(:status, account: bill, reblog: status, uri: 'hoge')
end
it 'removes status from author\'s home feed' do
subject.call(status)
expect(HomeFeed.new(alice).get(10).pluck(:id)).to_not include(status.id)
end
it 'removes status from local follower\'s home feed' do
subject.call(status)
expect(HomeFeed.new(jeff).get(10).pluck(:id)).to_not include(status.id)
end
it 'publishes to public media timeline' do
it 'removes status from notifications and from author and local follower home feeds, publishes to media timeline, sends delete activities' do
allow(redis).to receive(:publish).with(any_args)
subject.call(status)
expect { subject.call(status) }
.to remove_status_from_notifications
expect(redis).to have_received(:publish).with('timeline:public:media', Oj.dump(event: :delete, payload: status.id.to_s))
end
expect(home_feed_ids(alice))
.to_not include(status.id)
expect(home_feed_ids(jeff))
.to_not include(status.id)
it 'sends Delete activity to followers' do
subject.call(status)
expect(redis)
.to have_received(:publish).with('timeline:public:media', Oj.dump(event: :delete, payload: status.id.to_s))
expect(delete_delivery(hank, status))
.to have_been_made.once
end
it 'sends Delete activity to rebloggers' do
subject.call(status)
expect(delete_delivery(bill, status))
.to have_been_made.once
end
it 'remove status from notifications' do
expect { subject.call(status) }.to change {
Notification.where(activity_type: 'Favourite', from_account: jeff, account: alice).count
}.from(1).to(0)
def home_feed_ids(personage)
HomeFeed
.new(personage)
.get(10)
.pluck(:id)
end
def remove_status_from_notifications
change { Notification.where(activity_type: 'Favourite', from_account: jeff, account: alice).count }
.from(1)
.to(0)
end
def delete_delivery(target, status)