mirror of
https://github.com/discourse/discourse.git
synced 2025-06-25 01:30:17 +08:00
DEV: Drop user_stats count column constraints (#15949)
We added this constraint in 5bd55acf835e79ba8f8b655c684035c3f2293652 but it is causing problems in hosted sites and is catching the issue too far down the line. This commit removes the constraint for now, and also fixes an issue found with PostDestroyer which wasn't using the UserStatCountUpdater when updating post_count and thus was causing negative numbers to occur.
This commit is contained in:
@ -442,6 +442,21 @@ describe PostDestroyer do
|
||||
expect(user2.user_stat.post_count).to eq(0)
|
||||
end
|
||||
|
||||
it "does not update post_count or topic_count to a negative number" do
|
||||
user1 = post.user
|
||||
reply2 = create_post(topic_id: post.topic_id, user: user1)
|
||||
expect(user1.user_stat.topic_count).to eq(1)
|
||||
expect(user1.user_stat.post_count).to eq(1)
|
||||
|
||||
user1.user_stat.update!(topic_count: 0)
|
||||
user1.user_stat.update!(post_count: 0)
|
||||
|
||||
PostDestroyer.new(admin, post).destroy
|
||||
user1.reload
|
||||
expect(user1.user_stat.topic_count).to eq(0)
|
||||
expect(user1.user_stat.post_count).to eq(0)
|
||||
end
|
||||
|
||||
it 'deletes the published page associated with the topic' do
|
||||
slug = 'my-published-page'
|
||||
publish_result = PublishedPage.publish!(admin, post.topic, slug)
|
||||
|
Reference in New Issue
Block a user