Misc coverage improvements re: sidekiq/inline (#28651)

master
Matt Jankowski 2024-01-09 04:40:08 -05:00 committed by GitHub
parent 68f06f1fd4
commit 5dc634796a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 95 additions and 1 deletions

View File

@ -58,6 +58,88 @@ RSpec.describe Notification do
end
end
describe 'Setting account from activity_type' do
context 'when activity_type is a Status' do
it 'sets the notification from_account correctly' do
status = Fabricate(:status)
notification = Fabricate.build(:notification, activity_type: 'Status', activity: status)
expect(notification.from_account).to eq(status.account)
end
end
context 'when activity_type is a Follow' do
it 'sets the notification from_account correctly' do
follow = Fabricate(:follow)
notification = Fabricate.build(:notification, activity_type: 'Follow', activity: follow)
expect(notification.from_account).to eq(follow.account)
end
end
context 'when activity_type is a Favourite' do
it 'sets the notification from_account correctly' do
favourite = Fabricate(:favourite)
notification = Fabricate.build(:notification, activity_type: 'Favourite', activity: favourite)
expect(notification.from_account).to eq(favourite.account)
end
end
context 'when activity_type is a FollowRequest' do
it 'sets the notification from_account correctly' do
follow_request = Fabricate(:follow_request)
notification = Fabricate.build(:notification, activity_type: 'FollowRequest', activity: follow_request)
expect(notification.from_account).to eq(follow_request.account)
end
end
context 'when activity_type is a Poll' do
it 'sets the notification from_account correctly' do
poll = Fabricate(:poll)
notification = Fabricate.build(:notification, activity_type: 'Poll', activity: poll)
expect(notification.from_account).to eq(poll.account)
end
end
context 'when activity_type is a Report' do
it 'sets the notification from_account correctly' do
report = Fabricate(:report)
notification = Fabricate.build(:notification, activity_type: 'Report', activity: report)
expect(notification.from_account).to eq(report.account)
end
end
context 'when activity_type is a Mention' do
it 'sets the notification from_account correctly' do
mention = Fabricate(:mention)
notification = Fabricate.build(:notification, activity_type: 'Mention', activity: mention)
expect(notification.from_account).to eq(mention.status.account)
end
end
context 'when activity_type is an Account' do
it 'sets the notification from_account correctly' do
account = Fabricate(:account)
notification = Fabricate.build(:notification, activity_type: 'Account', account: account)
expect(notification.account).to eq(account)
end
end
end
describe '.preload_cache_collection_target_statuses' do
subject do
described_class.preload_cache_collection_target_statuses(notifications) do |target_statuses|

View File

@ -20,6 +20,8 @@ RSpec.describe FanOutOnWriteService, type: :service do
ProcessMentionsService.new.call(status)
ProcessHashtagsService.new.call(status)
Fabricate(:media_attachment, status: status, account: alice)
allow(redis).to receive(:publish)
subject.call(status)
@ -49,6 +51,7 @@ RSpec.describe FanOutOnWriteService, type: :service do
it 'is broadcast to the public stream' do
expect(redis).to have_received(:publish).with('timeline:public', anything)
expect(redis).to have_received(:publish).with('timeline:public:local', anything)
expect(redis).to have_received(:publish).with('timeline:public:media', anything)
end
end

View File

@ -20,7 +20,8 @@ RSpec.describe RemoveStatusService, type: :service do
end
context 'when removed status is not a reblog' do
let!(:status) { PostStatusService.new.call(alice, text: "Hello @#{bob.pretty_acct} ThisIsASecret") }
let!(:media_attachment) { Fabricate(:media_attachment, account: alice) }
let!(:status) { PostStatusService.new.call(alice, text: "Hello @#{bob.pretty_acct} ThisIsASecret", media_ids: [media_attachment.id]) }
before do
FavouriteService.new.call(jeff, status)
@ -37,6 +38,14 @@ RSpec.describe RemoveStatusService, type: :service do
expect(HomeFeed.new(jeff).get(10).pluck(:id)).to_not include(status.id)
end
it 'publishes to public media timeline' do
allow(redis).to receive(:publish).with(any_args)
subject.call(status)
expect(redis).to have_received(:publish).with('timeline:public:media', Oj.dump(event: :delete, payload: status.id.to_s))
end
it 'sends Delete activity to followers' do
subject.call(status)
expect(a_request(:post, hank.inbox_url).with(