DEV: correct revision debouncer for backup draft
We were debouncing on update_at which we kept on pushing forward, this was leading to not enough revisions.
This commit is contained in:
parent
3314aa9f88
commit
cb0443792b
|
@ -137,7 +137,7 @@ class Draft < ActiveRecord::Base
|
|||
).create
|
||||
BackupDraftPost.create!(user_id: user.id, key: key, post_id: post.id)
|
||||
end
|
||||
elsif post.updated_at > 5.minutes.ago
|
||||
elsif post.last_version_at > 5.minutes.ago
|
||||
# bypass all validations here to maximize speed
|
||||
post.update_columns(
|
||||
raw: draft_body,
|
||||
|
|
|
@ -19,13 +19,17 @@ describe Draft do
|
|||
|
||||
Draft.set(user, "new_private_message", 0, draft.to_json)
|
||||
draft["reply"] = "test" * 100
|
||||
|
||||
half_grace = (SiteSetting.editing_grace_period / 2 + 1).seconds
|
||||
|
||||
freeze_time half_grace.from_now
|
||||
Draft.set(user, "new_private_message", 77, draft.to_json)
|
||||
|
||||
draft_post = BackupDraftPost.find_by(user_id: user.id, key: "new_private_message").post
|
||||
|
||||
expect(draft_post.revisions.count).to eq(0)
|
||||
|
||||
freeze_time 10.minutes.from_now
|
||||
freeze_time half_grace.from_now
|
||||
|
||||
# this should trigger a post revision as 10 minutes have passed
|
||||
draft["reply"] = "hello"
|
||||
|
|
Loading…
Reference in New Issue