From f6ad213192ab1d7b0049bcf51a53f3132996cf99 Mon Sep 17 00:00:00 2001 From: Claire Date: Mon, 7 Sep 2026 09:51:46 +0000 Subject: [PATCH] Fix account deletion not deleting generated annual reports (#40394) --- app/models/concerns/account/associations.rb | 1 + app/services/delete_account_service.rb | 2 ++ spec/services/delete_account_service_spec.rb | 2 ++ 3 files changed, 5 insertions(+) diff --git a/app/models/concerns/account/associations.rb b/app/models/concerns/account/associations.rb index 8c26a4da64..1a3d5f6845 100644 --- a/app/models/concerns/account/associations.rb +++ b/app/models/concerns/account/associations.rb @@ -40,6 +40,7 @@ module Account::Associations has_many :statuses has_many :keypairs has_many :email_subscriptions + has_many :generated_annual_reports has_one :deletion_request, class_name: 'AccountDeletionRequest' has_one :follow_recommendation_suppression diff --git a/app/services/delete_account_service.rb b/app/services/delete_account_service.rb index e9ae117ceb..4f94a3ef71 100644 --- a/app/services/delete_account_service.rb +++ b/app/services/delete_account_service.rb @@ -28,6 +28,7 @@ class DeleteAccountService < BaseService scheduled_statuses status_pins tag_follows + generated_annual_reports ).freeze # The following associations have no important side-effects @@ -53,6 +54,7 @@ class DeleteAccountService < BaseService scheduled_statuses status_pins tag_follows + generated_annual_reports ).freeze ASSOCIATIONS_ON_DESTROY = %w( diff --git a/spec/services/delete_account_service_spec.rb b/spec/services/delete_account_service_spec.rb index f3eb0ca70f..291ae8035c 100644 --- a/spec/services/delete_account_service_spec.rb +++ b/spec/services/delete_account_service_spec.rb @@ -26,6 +26,7 @@ RSpec.describe DeleteAccountService do let!(:follow_notification) { Fabricate(:notification, account: local_follower, activity: active_relationship, type: :follow) } let!(:account_note) { Fabricate(:account_note, account: account) } + let!(:generated_annual_report) { Fabricate(:generated_annual_report, account: account) } it 'deletes associated owned and target records and target notifications' do subject @@ -48,6 +49,7 @@ RSpec.describe DeleteAccountService do expect { poll_vote.reload }.to raise_error(ActiveRecord::RecordNotFound) expect { account_note.reload }.to raise_error(ActiveRecord::RecordNotFound) expect { collection.reload }.to raise_error(ActiveRecord::RecordNotFound) + expect { generated_annual_report.reload }.to raise_error(ActiveRecord::RecordNotFound) end def expect_deletion_of_associated_target_records