Reduce factory usage across spec/services
area (#32098)
This commit is contained in:
parent
4fe7f213a6
commit
e4e07b1c34
21 changed files with 567 additions and 641 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue