From ed7b5c091b62d63e695d2f1ff946e021fb37fa18 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Wed, 6 Dec 2023 03:51:09 -0500 Subject: [PATCH] Remove double subject call in `services/delete_account_service` spec (#28212) --- spec/services/delete_account_service_spec.rb | 25 +++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/spec/services/delete_account_service_spec.rb b/spec/services/delete_account_service_spec.rb index 68ab491e4e..8a19d3cf74 100644 --- a/spec/services/delete_account_service_spec.rb +++ b/spec/services/delete_account_service_spec.rb @@ -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