diff --git a/app/models/concerns/account/associations.rb b/app/models/concerns/account/associations.rb index 8c26a4da648..1a3d5f68456 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 cdd40fb8719..c3d08390e2a 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 f3eb0ca70fb..291ae8035c9 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