FIX: when destroying users we were leaving drafts behind

This commit is contained in:
Sam 2015-08-24 16:05:08 +10:00
parent 8b660066ca
commit 94f05a40de
2 changed files with 12 additions and 0 deletions

View File

@ -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]

View File

@ -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) }