diff --git a/app/services/user_destroyer.rb b/app/services/user_destroyer.rb index 2b70d181c..edf842f9f 100644 --- a/app/services/user_destroyer.rb +++ b/app/services/user_destroyer.rb @@ -20,6 +20,7 @@ class UserDestroyer User.transaction do + Draft.where(user_id: user.id).delete_all QueuedPost.where(user_id: user.id).delete_all if opts[:delete_posts] diff --git a/spec/services/user_destroyer_spec.rb b/spec/services/user_destroyer_spec.rb index d8507aaef..5e023d30c 100644 --- a/spec/services/user_destroyer_spec.rb +++ b/spec/services/user_destroyer_spec.rb @@ -85,6 +85,17 @@ describe UserDestroyer do end + context "with a draft" do + let(:user) { Fabricate(:user) } + let(:admin) { Fabricate(:admin) } + let!(:draft) { Draft.set(user, 'test', 1, 'test') } + + it "removed the draft" do + UserDestroyer.new(admin).destroy(user) + expect(Draft.where(user_id: user.id).count).to eq(0) + end + end + context 'user has posts' do let!(:topic_starter) { Fabricate(:user) } let!(:topic) { Fabricate(:topic, user: topic_starter) }