Merge pull request #14 from sharelatex/ja-dont-return-blank-clients

Don't return a user if there is no entry
This commit is contained in:
James Allen 2017-05-16 11:14:54 +01:00 committed by GitHub
commit db824d9730
2 changed files with 11 additions and 4 deletions

View file

@ -50,7 +50,7 @@ module.exports =
_getConnectedUser: (project_id, client_id, callback)->
rclient.hgetall Keys.connectedUser({project_id, client_id}), (err, result)->
if !result?
if !result? or Object.keys(result).length == 0
result =
connected : false
client_id:client_id

View file

@ -122,7 +122,7 @@ describe "ConnectedUsersManager", ->
describe "_getConnectedUser", ->
it "should get the user returning connected if there is a value", (done)->
it "should return a connected user if there is a user object", (done)->
cursorData = JSON.stringify(cursorData:{row:1})
@rClient.hgetall.callsArgWith(1, null, {connected_at:new Date(), cursorData})
@ConnectedUsersManager._getConnectedUser @project_id, @client_id, (err, result)=>
@ -130,8 +130,15 @@ describe "ConnectedUsersManager", ->
result.client_id.should.equal @client_id
done()
it "should get the user returning connected if there is a value", (done)->
@rClient.hgetall.callsArgWith(1)
it "should return a not connected user if there is no object", (done)->
@rClient.hgetall.callsArgWith(1, null, null)
@ConnectedUsersManager._getConnectedUser @project_id, @client_id, (err, result)=>
result.connected.should.equal false
result.client_id.should.equal @client_id
done()
it "should return a not connected user if there is an empty object", (done)->
@rClient.hgetall.callsArgWith(1, null, {})
@ConnectedUsersManager._getConnectedUser @project_id, @client_id, (err, result)=>
result.connected.should.equal false
result.client_id.should.equal @client_id