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

@ -24,32 +24,38 @@ RSpec.describe BatchedRemoveStatusService, :inline_jobs do
status_alice_hello
status_alice_other
end
it 'removes status records, removes from author and local follower feeds, notifies stream, sends delete' do
subject.call([status_alice_hello, status_alice_other])
expect { Status.find(status_alice_hello.id) }
.to raise_error ActiveRecord::RecordNotFound
expect { Status.find(status_alice_other.id) }
.to raise_error ActiveRecord::RecordNotFound
expect(feed_ids_for(alice))
.to_not include(status_alice_hello.id, status_alice_other.id)
expect(feed_ids_for(jeff))
.to_not include(status_alice_hello.id, status_alice_other.id)
expect(redis)
.to have_received(:publish)
.with("timeline:#{jeff.id}", any_args).at_least(:once)
expect(redis)
.to have_received(:publish)
.with('timeline:public', any_args).at_least(:once)
expect(a_request(:post, 'http://example.com/inbox'))
.to have_been_made.at_least_once
end
it 'removes statuses' do
expect { Status.find(status_alice_hello.id) }.to raise_error ActiveRecord::RecordNotFound
expect { Status.find(status_alice_other.id) }.to raise_error ActiveRecord::RecordNotFound
end
it 'removes statuses from author\'s home feed' do
expect(HomeFeed.new(alice).get(10).pluck(:id)).to_not include(status_alice_hello.id, status_alice_other.id)
end
it 'removes statuses from local follower\'s home feed' do
expect(HomeFeed.new(jeff).get(10).pluck(:id)).to_not include(status_alice_hello.id, status_alice_other.id)
end
it 'notifies streaming API of followers' do
expect(redis).to have_received(:publish).with("timeline:#{jeff.id}", any_args).at_least(:once)
end
it 'notifies streaming API of public timeline' do
expect(redis).to have_received(:publish).with('timeline:public', any_args).at_least(:once)
end
it 'sends delete activity to followers' do
expect(a_request(:post, 'http://example.com/inbox')).to have_been_made.at_least_once
def feed_ids_for(account)
HomeFeed
.new(account)
.get(10)
.pluck(:id)
end
end