1
0
mirror of https://github.com/mastodon/mastodon synced 2024-11-27 14:28:24 +09:00

Remove double subject call in services/delete_account_service spec (#28212)

This commit is contained in:
Matt Jankowski 2023-12-06 03:51:09 -05:00 committed by GitHub
parent be6bb1a10d
commit ed7b5c091b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -27,8 +27,15 @@ RSpec.describe DeleteAccountService, type: :service do
let!(:account_note) { Fabricate(:account_note, account: account) }
it 'deletes associated owned records' do
expect { subject }.to change {
it 'deletes associated owned and target records and target notifications' do
expect { subject }
.to delete_associated_owned_records
.and delete_associated_target_records
.and delete_associated_target_notifications
end
def delete_associated_owned_records
change do
[
account.statuses,
account.media_attachments,
@ -39,23 +46,23 @@ RSpec.describe DeleteAccountService, type: :service do
account.polls,
account.account_notes,
].map(&:count)
}.from([2, 1, 1, 1, 1, 1, 1, 1]).to([0, 0, 0, 0, 0, 0, 0, 0])
end.from([2, 1, 1, 1, 1, 1, 1, 1]).to([0, 0, 0, 0, 0, 0, 0, 0])
end
it 'deletes associated target records' do
expect { subject }.to change {
def delete_associated_target_records
change do
[
AccountPin.where(target_account: account),
].map(&:count)
}.from([1]).to([0])
end.from([1]).to([0])
end
it 'deletes associated target notifications' do
expect { subject }.to change {
def delete_associated_target_notifications
change do
%w(
poll favourite status mention follow
).map { |type| Notification.where(type: type).count }
}.from([1, 1, 1, 1, 1]).to([0, 0, 0, 0, 0])
end.from([1, 1, 1, 1, 1]).to([0, 0, 0, 0, 0])
end
end