Fix repeated Delete/Undo assertion in remove status service spec (#30715)

shrike
Matt Jankowski 2024-06-17 06:21:29 -04:00 committed by GitHub
parent c739b7f851
commit f287462f76
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 46 additions and 47 deletions

View File

@ -48,30 +48,16 @@ RSpec.describe RemoveStatusService, :sidekiq_inline do
it 'sends Delete activity to followers' do it 'sends Delete activity to followers' do
subject.call(status) subject.call(status)
expect(a_request(:post, hank.inbox_url).with(
body: hash_including({ expect(delete_delivery(hank, status))
'type' => 'Delete', .to have_been_made.once
'object' => {
'type' => 'Tombstone',
'id' => ActivityPub::TagManager.instance.uri_for(status),
'atomUri' => OStatus::TagManager.instance.uri_for(status),
},
})
)).to have_been_made.once
end end
it 'sends Delete activity to rebloggers' do it 'sends Delete activity to rebloggers' do
subject.call(status) subject.call(status)
expect(a_request(:post, bill.inbox_url).with(
body: hash_including({ expect(delete_delivery(bill, status))
'type' => 'Delete', .to have_been_made.once
'object' => {
'type' => 'Tombstone',
'id' => ActivityPub::TagManager.instance.uri_for(status),
'atomUri' => OStatus::TagManager.instance.uri_for(status),
},
})
)).to have_been_made.once
end end
it 'remove status from notifications' do it 'remove status from notifications' do
@ -79,6 +65,22 @@ RSpec.describe RemoveStatusService, :sidekiq_inline do
Notification.where(activity_type: 'Favourite', from_account: jeff, account: alice).count Notification.where(activity_type: 'Favourite', from_account: jeff, account: alice).count
}.from(1).to(0) }.from(1).to(0)
end end
def delete_delivery(target, status)
a_request(:post, target.inbox_url)
.with(body: delete_activity_for(status))
end
def delete_activity_for(status)
hash_including(
'type' => 'Delete',
'object' => {
'type' => 'Tombstone',
'id' => ActivityPub::TagManager.instance.uri_for(status),
'atomUri' => OStatus::TagManager.instance.uri_for(status),
}
)
end
end end
context 'when removed status is a private self-reblog' do context 'when removed status is a private self-reblog' do
@ -87,15 +89,9 @@ RSpec.describe RemoveStatusService, :sidekiq_inline do
it 'sends Undo activity to followers' do it 'sends Undo activity to followers' do
subject.call(status) subject.call(status)
expect(a_request(:post, hank.inbox_url).with(
body: hash_including({ expect(undo_delivery(hank, original_status))
'type' => 'Undo', .to have_been_made.once
'object' => hash_including({
'type' => 'Announce',
'object' => ActivityPub::TagManager.instance.uri_for(original_status),
}),
})
)).to have_been_made.once
end end
end end
@ -105,15 +101,9 @@ RSpec.describe RemoveStatusService, :sidekiq_inline do
it 'sends Undo activity to followers' do it 'sends Undo activity to followers' do
subject.call(status) subject.call(status)
expect(a_request(:post, hank.inbox_url).with(
body: hash_including({ expect(undo_delivery(hank, original_status))
'type' => 'Undo', .to have_been_made.once
'object' => hash_including({
'type' => 'Announce',
'object' => ActivityPub::TagManager.instance.uri_for(original_status),
}),
})
)).to have_been_made.once
end end
end end
@ -123,15 +113,24 @@ RSpec.describe RemoveStatusService, :sidekiq_inline do
it 'sends Undo activity to followers' do it 'sends Undo activity to followers' do
subject.call(status) subject.call(status)
expect(a_request(:post, bill.inbox_url).with(
body: hash_including({ expect(undo_delivery(bill, original_status))
'type' => 'Undo', .to have_been_made.once
'object' => hash_including({
'type' => 'Announce',
'object' => ActivityPub::TagManager.instance.uri_for(original_status),
}),
})
)).to have_been_made.once
end end
end end
def undo_delivery(target, status)
a_request(:post, target.inbox_url)
.with(body: undo_activity_for(status))
end
def undo_activity_for(status)
hash_including(
'type' => 'Undo',
'object' => hash_including(
'type' => 'Announce',
'object' => ActivityPub::TagManager.instance.uri_for(status)
)
)
end
end end