mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 06:04:11 +08:00
FIX: only count regular posts in user stats when deleting
This commit is contained in:
parent
30689783db
commit
21dd2ccd43
|
@ -231,8 +231,8 @@ class PostDestroyer
|
|||
author.user_stat.first_post_created_at = author.posts.order('created_at ASC').first.try(:created_at)
|
||||
end
|
||||
|
||||
unless @topic.nil? && !@post.is_first_post?
|
||||
author.user_stat.post_count -= 1 # TODO: deleting a regular post
|
||||
if @post.post_type == Post.types[:regular] && !(@topic.nil? && !@post.is_first_post?)
|
||||
author.user_stat.post_count -= 1
|
||||
end
|
||||
author.user_stat.topic_count -= 1 if @post.is_first_post?
|
||||
|
||||
|
|
|
@ -308,6 +308,21 @@ describe PostDestroyer do
|
|||
author.reload
|
||||
}.to change { author.post_count }.by(-1)
|
||||
end
|
||||
|
||||
it "doesn't count whispers" do
|
||||
user_stat = admin.user_stat
|
||||
whisper = PostCreator.new(
|
||||
admin,
|
||||
topic_id: post.topic.id,
|
||||
reply_to_post_number: 1,
|
||||
post_type: Post.types[:whisper],
|
||||
raw: 'this is a whispered reply'
|
||||
).create
|
||||
expect(user_stat.reload.post_count).to eq(0)
|
||||
expect {
|
||||
PostDestroyer.new(admin, whisper).destroy
|
||||
}.to_not change { user_stat.reload.post_count }
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user