mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 09:26:54 -06:00
FIX: Post count wasn't recovered when a post is recovered.
This commit is contained in:
parent
142b74b01b
commit
0c8dd28395
@ -64,6 +64,12 @@ class PostDestroyer
|
||||
|
||||
def staff_recovered
|
||||
@post.recover!
|
||||
|
||||
if author = @post.user
|
||||
author.user_stat.post_count += 1
|
||||
author.user_stat.save!
|
||||
end
|
||||
|
||||
@post.publish_change_to_clients! :recovered
|
||||
TopicTrackingState.publish_recover(@post.topic) if @post.topic && @post.post_number == 1
|
||||
end
|
||||
|
@ -162,6 +162,34 @@ describe PostDestroyer do
|
||||
post_action = author.user_actions.where(action_type: UserAction::REPLY, target_post_id: reply.id).first
|
||||
expect(post_action).to be_present
|
||||
end
|
||||
|
||||
describe "post_count recovery" do
|
||||
before do
|
||||
post
|
||||
@user = post.user
|
||||
expect(@user.user_stat.post_count).to eq(1)
|
||||
end
|
||||
|
||||
context "recovered by user" do
|
||||
it "should increment the user's post count" do
|
||||
PostDestroyer.new(@user, post).destroy
|
||||
expect(@user.user_stat.post_count).to eq(1)
|
||||
|
||||
PostDestroyer.new(@user, post.reload).recover
|
||||
expect(@user.reload.user_stat.post_count).to eq(1)
|
||||
end
|
||||
end
|
||||
|
||||
context "recovered by admin" do
|
||||
it "should increment the user's post count" do
|
||||
PostDestroyer.new(moderator, post).destroy
|
||||
expect(@user.user_stat.post_count).to eq(0)
|
||||
|
||||
PostDestroyer.new(admin, post).recover
|
||||
expect(@user.reload.user_stat.post_count).to eq(1)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'basic destroying' do
|
||||
|
Loading…
Reference in New Issue
Block a user