0
0
Fork 0

Fix owned account notes not being deleted when an account is deleted (#16579)

* Add account_notes relationship

* Add tests

* Fix owned account notes not being deleted when an account is deleted

* Add post-migration to clean up orphaned account notes
This commit is contained in:
Claire 2021-08-08 15:29:57 +02:00 committed by GitHub
parent 818e0b314f
commit 763ab0c7eb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 31 additions and 2 deletions

View file

@ -21,6 +21,8 @@ RSpec.describe DeleteAccountService, type: :service do
let!(:favourite_notification) { Fabricate(:notification, account: local_follower, activity: favourite, type: :favourite) }
let!(:follow_notification) { Fabricate(:notification, account: local_follower, activity: active_relationship, type: :follow) }
let!(:account_note) { Fabricate(:account_note, account: account) }
subject do
-> { described_class.new.call(account) }
end
@ -35,8 +37,9 @@ RSpec.describe DeleteAccountService, type: :service do
account.active_relationships,
account.passive_relationships,
account.polls,
account.account_notes,
].map(&:count)
}.from([2, 1, 1, 1, 1, 1, 1]).to([0, 0, 0, 0, 0, 0, 0])
}.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