mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 10:20:58 -06:00
FIX: when advancing draft sequence remove old drafts
This commit is contained in:
parent
afafa30989
commit
d459cb95dc
@ -11,6 +11,7 @@ class DraftSequence < ActiveRecord::Base
|
|||||||
c.sequence ||= 0
|
c.sequence ||= 0
|
||||||
c.sequence += 1
|
c.sequence += 1
|
||||||
c.save
|
c.save
|
||||||
|
exec_sql("DELETE FROM drafts WHERE user_id = :user_id AND draft_key = :draft_key AND sequence < :sequence", draft_key: key, user_id: user_id, sequence: c.sequence)
|
||||||
c.sequence
|
c.sequence
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -42,6 +42,7 @@ describe Draft do
|
|||||||
_t = Fabricate(:topic, user: u)
|
_t = Fabricate(:topic, user: u)
|
||||||
s = DraftSequence.current(u, Draft::NEW_TOPIC)
|
s = DraftSequence.current(u, Draft::NEW_TOPIC)
|
||||||
expect(Draft.get(u, Draft::NEW_TOPIC, s)).to eq nil
|
expect(Draft.get(u, Draft::NEW_TOPIC, s)).to eq nil
|
||||||
|
expect(Draft.count).to eq 0
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'nukes new pm draft after a pm is created' do
|
it 'nukes new pm draft after a pm is created' do
|
||||||
|
Loading…
Reference in New Issue
Block a user