Remove double subject call in services/delete_account_service
spec (#28212)
This commit is contained in:
parent
be6bb1a10d
commit
ed7b5c091b
1 changed files with 16 additions and 9 deletions
|
@ -27,8 +27,15 @@ RSpec.describe DeleteAccountService, type: :service do
|
||||||
|
|
||||||
let!(:account_note) { Fabricate(:account_note, account: account) }
|
let!(:account_note) { Fabricate(:account_note, account: account) }
|
||||||
|
|
||||||
it 'deletes associated owned records' do
|
it 'deletes associated owned and target records and target notifications' do
|
||||||
expect { subject }.to change {
|
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.statuses,
|
||||||
account.media_attachments,
|
account.media_attachments,
|
||||||
|
@ -39,23 +46,23 @@ RSpec.describe DeleteAccountService, type: :service do
|
||||||
account.polls,
|
account.polls,
|
||||||
account.account_notes,
|
account.account_notes,
|
||||||
].map(&:count)
|
].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
|
end
|
||||||
|
|
||||||
it 'deletes associated target records' do
|
def delete_associated_target_records
|
||||||
expect { subject }.to change {
|
change do
|
||||||
[
|
[
|
||||||
AccountPin.where(target_account: account),
|
AccountPin.where(target_account: account),
|
||||||
].map(&:count)
|
].map(&:count)
|
||||||
}.from([1]).to([0])
|
end.from([1]).to([0])
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'deletes associated target notifications' do
|
def delete_associated_target_notifications
|
||||||
expect { subject }.to change {
|
change do
|
||||||
%w(
|
%w(
|
||||||
poll favourite status mention follow
|
poll favourite status mention follow
|
||||||
).map { |type| Notification.where(type: type).count }
|
).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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue