mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Update draft count after creating a post (#13884)
When a post is created, the draft sequence is increased and then older drafts are automatically executing a raw SQL query. This skipped the Draft model callbacks and did not update user's draft count. I fixed another problem related to a raw SQL query from Draft.cleanup! method.
This commit is contained in:
@@ -152,6 +152,7 @@ describe Draft do
|
||||
Draft.set(user, key, 0, 'draft')
|
||||
Draft.cleanup!
|
||||
expect(Draft.count).to eq 1
|
||||
expect(user.user_stat.draft_count).to eq(1)
|
||||
|
||||
seq = DraftSequence.next!(user, key)
|
||||
|
||||
@@ -161,6 +162,7 @@ describe Draft do
|
||||
Draft.cleanup!
|
||||
|
||||
expect(Draft.count).to eq 0
|
||||
expect(user.reload.user_stat.draft_count).to eq(0)
|
||||
|
||||
Draft.set(Fabricate(:user), Draft::NEW_TOPIC, 0, 'draft')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user