Delete classified listings when deleting user (#6258)
This commit is contained in:
parent
ac58bbeeb9
commit
ec8ee54559
3 changed files with 8 additions and 1 deletions
|
|
@ -46,7 +46,7 @@ class User < ApplicationRecord
|
|||
has_many :html_variants, dependent: :destroy
|
||||
has_many :page_views, dependent: :destroy
|
||||
has_many :credits, dependent: :destroy
|
||||
has_many :classified_listings
|
||||
has_many :classified_listings, dependent: :destroy
|
||||
has_many :poll_votes, dependent: :destroy
|
||||
has_many :poll_skips, dependent: :destroy
|
||||
has_many :backup_data, foreign_key: "instance_user_id", inverse_of: :instance_user, class_name: "BackupData", dependent: :delete_all
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ module Users
|
|||
user.profile_pins.delete_all
|
||||
user.rating_votes.delete_all
|
||||
user.tweets.delete_all
|
||||
user.classified_listings.delete_all
|
||||
|
||||
handle_feedback_messages(user)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -236,6 +236,12 @@ RSpec.describe "Internal::Users", type: :request do
|
|||
expect(user.follows.count).to eq(0)
|
||||
end
|
||||
|
||||
it "removes a user's classified listings" do
|
||||
create(:classified_listing, user: user)
|
||||
banish_user
|
||||
expect(user.classified_listings.count).to eq(0)
|
||||
end
|
||||
|
||||
it "creates an entry in the BanishedUsers table" do
|
||||
expect do
|
||||
banish_user
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue