mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Topic can have null user_id when user was nuked
This commit is contained in:
@@ -87,7 +87,10 @@ describe UserDestroyer do
|
||||
end
|
||||
|
||||
context 'user has posts' do
|
||||
let!(:post) { Fabricate(:post, user: @user) }
|
||||
let!(:topic_starter) { Fabricate(:user) }
|
||||
let!(:topic) { Fabricate(:topic, user: topic_starter) }
|
||||
let!(:first_post) { Fabricate(:post, user: topic_starter, topic: topic) }
|
||||
let!(:post) { Fabricate(:post, user: @user, topic: topic) }
|
||||
|
||||
context "delete_posts is false" do
|
||||
subject(:destroy) { UserDestroyer.new(@admin).destroy(@user) }
|
||||
@@ -123,6 +126,20 @@ describe UserDestroyer do
|
||||
post.reload.deleted_at.should_not be_nil
|
||||
post.user_id.should be_nil
|
||||
end
|
||||
|
||||
it "does not delete topics started by others in which the user has replies" do
|
||||
destroy
|
||||
topic.reload.deleted_at.should be_nil
|
||||
topic.user_id.should_not be_nil
|
||||
end
|
||||
|
||||
it "deletes topics started by the deleted user" do
|
||||
spammer_topic = Fabricate(:topic, user: @user)
|
||||
spammer_post = Fabricate(:post, user: @user, topic: spammer_topic)
|
||||
destroy
|
||||
spammer_topic.reload.deleted_at.should_not be_nil
|
||||
spammer_topic.user_id.should be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user