mirror of
https://github.com/discourse/discourse.git
synced 2025-06-08 00:27:32 +08:00
FIX: Always return 0 for non-human user current DraftSequence.
This commit is contained in:
@ -23,7 +23,7 @@ class DraftSequence < ActiveRecord::Base
|
|||||||
user_id = user
|
user_id = user
|
||||||
user_id = user.id unless user.is_a?(Integer)
|
user_id = user.id unless user.is_a?(Integer)
|
||||||
|
|
||||||
return nil if invalid_user_id?(user_id)
|
return 0 if invalid_user_id?(user_id)
|
||||||
|
|
||||||
# perf critical path
|
# perf critical path
|
||||||
r, _ = DB.query_single('select sequence from draft_sequences where user_id = ? and draft_key = ?', user_id, key)
|
r, _ = DB.query_single('select sequence from draft_sequences where user_id = ? and draft_key = ?', user_id, key)
|
||||||
|
@ -24,7 +24,7 @@ describe DraftSequence do
|
|||||||
|
|
||||||
it 'should return nil for non-human user' do
|
it 'should return nil for non-human user' do
|
||||||
user.id = -99999
|
user.id = -99999
|
||||||
expect(DraftSequence.current(user, 'test')).to eq(nil)
|
expect(DraftSequence.current(user, 'test')).to eq(0)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should return the right sequence' do
|
it 'should return the right sequence' do
|
||||||
|
Reference in New Issue
Block a user