FIX: remove likes and other post actions before nuking a user
This commit is contained in:
parent
682b0c4883
commit
379f4a87d5
|
@ -31,6 +31,9 @@ class UserDestroyer
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
user.post_actions.each do |post_action|
|
||||||
|
post_action.remove_act!(Discourse.system_user)
|
||||||
|
end
|
||||||
user.destroy.tap do |u|
|
user.destroy.tap do |u|
|
||||||
if u
|
if u
|
||||||
if opts[:block_email]
|
if opts[:block_email]
|
||||||
|
|
|
@ -264,6 +264,21 @@ describe UserDestroyer do
|
||||||
category.topic.user_id.should == Discourse.system_user.id
|
category.topic.user_id.should == Discourse.system_user.id
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'user liked things' do
|
||||||
|
before do
|
||||||
|
@topic = Fabricate(:topic, user: Fabricate(:user))
|
||||||
|
@post = Fabricate(:post, user: @topic.user, topic: @topic)
|
||||||
|
@like = PostAction.act(@user, @post, PostActionType.types[:like])
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should destroy the like' do
|
||||||
|
expect {
|
||||||
|
UserDestroyer.new(@admin).destroy(@user, {delete_posts: true})
|
||||||
|
}.to change { PostAction.count }.by(-1)
|
||||||
|
@post.reload.like_count.should == 0
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue