mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-12-03 12:27:35 -05:00
FIX: when destroying users we were leaving drafts behind
This commit is contained in:
parent
8b660066ca
commit
94f05a40de
2 changed files with 12 additions and 0 deletions
|
@ -20,6 +20,7 @@ class UserDestroyer
|
||||||
|
|
||||||
User.transaction do
|
User.transaction do
|
||||||
|
|
||||||
|
Draft.where(user_id: user.id).delete_all
|
||||||
QueuedPost.where(user_id: user.id).delete_all
|
QueuedPost.where(user_id: user.id).delete_all
|
||||||
|
|
||||||
if opts[:delete_posts]
|
if opts[:delete_posts]
|
||||||
|
|
|
@ -85,6 +85,17 @@ describe UserDestroyer do
|
||||||
|
|
||||||
end
|
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
|
context 'user has posts' do
|
||||||
let!(:topic_starter) { Fabricate(:user) }
|
let!(:topic_starter) { Fabricate(:user) }
|
||||||
let!(:topic) { Fabricate(:topic, user: topic_starter) }
|
let!(:topic) { Fabricate(:topic, user: topic_starter) }
|
||||||
|
|
Loading…
Reference in a new issue