diff --git a/app/models/draft_sequence.rb b/app/models/draft_sequence.rb index 411d77492f4..681a8bcb2ef 100644 --- a/app/models/draft_sequence.rb +++ b/app/models/draft_sequence.rb @@ -23,7 +23,7 @@ class DraftSequence < ActiveRecord::Base user_id = user 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 r, _ = DB.query_single('select sequence from draft_sequences where user_id = ? and draft_key = ?', user_id, key) diff --git a/spec/models/draft_sequence_spec.rb b/spec/models/draft_sequence_spec.rb index 282b129f158..47747c15d5c 100644 --- a/spec/models/draft_sequence_spec.rb +++ b/spec/models/draft_sequence_spec.rb @@ -24,7 +24,7 @@ describe DraftSequence do it 'should return nil for non-human user' do user.id = -99999 - expect(DraftSequence.current(user, 'test')).to eq(nil) + expect(DraftSequence.current(user, 'test')).to eq(0) end it 'should return the right sequence' do