mirror of
https://github.com/discourse/discourse.git
synced 2025-02-16 18:24:52 -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
|
def staff_recovered
|
||||||
@post.recover!
|
@post.recover!
|
||||||
|
|
||||||
|
if author = @post.user
|
||||||
|
author.user_stat.post_count += 1
|
||||||
|
author.user_stat.save!
|
||||||
|
end
|
||||||
|
|
||||||
@post.publish_change_to_clients! :recovered
|
@post.publish_change_to_clients! :recovered
|
||||||
TopicTrackingState.publish_recover(@post.topic) if @post.topic && @post.post_number == 1
|
TopicTrackingState.publish_recover(@post.topic) if @post.topic && @post.post_number == 1
|
||||||
end
|
end
|
||||||
|
@ -162,6 +162,34 @@ describe PostDestroyer do
|
|||||||
post_action = author.user_actions.where(action_type: UserAction::REPLY, target_post_id: reply.id).first
|
post_action = author.user_actions.where(action_type: UserAction::REPLY, target_post_id: reply.id).first
|
||||||
expect(post_action).to be_present
|
expect(post_action).to be_present
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
describe 'basic destroying' do
|
describe 'basic destroying' do
|
||||||
|
Loading…
Reference in New Issue
Block a user