mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 14:13:38 +08:00
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
|
||||
user.post_actions.each do |post_action|
|
||||
post_action.remove_act!(Discourse.system_user)
|
||||
end
|
||||
user.destroy.tap do |u|
|
||||
if u
|
||||
if opts[:block_email]
|
||||
|
|
|
@ -264,6 +264,21 @@ describe UserDestroyer do
|
|||
category.topic.user_id.should == Discourse.system_user.id
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue
Block a user