mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Return early if there are no keys to delete
This commit is contained in:
parent
fc6cf75ad5
commit
dda0841af3
2 changed files with 23 additions and 0 deletions
|
@ -72,6 +72,9 @@ module.exports = UserSessionsManager =
|
|||
logger.err {err, user_id: user._id, sessionSetKey}, "error getting contents of UserSessions set"
|
||||
return callback(err)
|
||||
keysToDelete = _.filter(sessionKeys, (k) -> k not in retain)
|
||||
if keysToDelete.length == 0
|
||||
logger.log {user_id: user._id}, "no sessions in UserSessions set to delete, returning"
|
||||
return callback(null)
|
||||
logger.log {user_id: user._id, count: keysToDelete.length}, "deleting sessions for user"
|
||||
rclient.multi()
|
||||
.del(keysToDelete)
|
||||
|
|
|
@ -339,6 +339,26 @@ describe 'UserSessionsManager', ->
|
|||
@rclient.exec.callCount.should.equal 0
|
||||
done()
|
||||
|
||||
describe 'when there are no keys to delete', ->
|
||||
|
||||
beforeEach ->
|
||||
@rclient.smembers.callsArgWith(1, null, [])
|
||||
|
||||
it 'should not produce an error', (done) ->
|
||||
@call (err) =>
|
||||
expect(err).to.not.be.instanceof Error
|
||||
expect(err).to.equal null
|
||||
done()
|
||||
|
||||
it 'should not do the delete operation', (done) ->
|
||||
@call (err) =>
|
||||
@rclient.smembers.callCount.should.equal 1
|
||||
@rclient.multi.callCount.should.equal 0
|
||||
@rclient.del.callCount.should.equal 0
|
||||
@rclient.srem.callCount.should.equal 0
|
||||
@rclient.exec.callCount.should.equal 0
|
||||
done()
|
||||
|
||||
describe 'touch', ->
|
||||
|
||||
beforeEach ->
|
||||
|
|
Loading…
Reference in a new issue