marksUserAsDisconnected -> markUserAsDisconnected

This commit is contained in:
Henry Oswald 2014-07-10 17:01:42 +01:00
parent 01ad313133
commit d737197e95
4 changed files with 8 additions and 8 deletions

View file

@ -23,7 +23,7 @@ module.exports =
rclient.setex buildUserKey(project_id, user_id), new Date(), ONE_HOUR_IN_S * 6, cb rclient.setex buildUserKey(project_id, user_id), new Date(), ONE_HOUR_IN_S * 6, cb
], callback ], callback
marksUserAsDisconnected: (project_id, user_id, callback)-> markUserAsDisconnected: (project_id, user_id, callback)->
logger.log project_id:project_id, user_id:user_id, "marking user as disconnected" logger.log project_id:project_id, user_id:user_id, "marking user as disconnected"
async.series [ async.series [
(cb)-> (cb)->

View file

@ -68,7 +68,7 @@ module.exports = EditorController =
return if error? or !project_id? return if error? or !project_id?
EditorRealTimeController.emitToRoom(project_id, "clientTracking.clientDisconnected", client.id) EditorRealTimeController.emitToRoom(project_id, "clientTracking.clientDisconnected", client.id)
EditorRealTimeController.emitToRoom(project_id, "ConnectedUsers.userDissconected", user) EditorRealTimeController.emitToRoom(project_id, "ConnectedUsers.userDissconected", user)
ConnectedUsersManager.marksUserAsDisconnected project_id, user._id, -> ConnectedUsersManager.markUserAsDisconnected project_id, user._id, ->
logger.log user_id:user._id, project_id:project_id, "user leaving project" logger.log user_id:user._id, project_id:project_id, "user leaving project"
self.flushProjectIfEmpty(project_id) self.flushProjectIfEmpty(project_id)

View file

@ -53,18 +53,18 @@ describe "ConnectedUsersManager", ->
@rClient.sadd.calledWith("users_in_project:#{@project_id}", @user_id).should.equal true @rClient.sadd.calledWith("users_in_project:#{@project_id}", @user_id).should.equal true
done() done()
describe "marksUserAsDisconnected", -> describe "markUserAsDisconnected", ->
beforeEach -> beforeEach ->
@rClient.srem.callsArgWith(2) @rClient.srem.callsArgWith(2)
@rClient.del.callsArgWith(1) @rClient.del.callsArgWith(1)
it "should remove the user from the set", (done)-> it "should remove the user from the set", (done)->
@ConnectedUsersManager.marksUserAsDisconnected @project_id, @user_id, (err)=> @ConnectedUsersManager.markUserAsDisconnected @project_id, @user_id, (err)=>
@rClient.srem.calledWith("users_in_project:#{@project_id}", @user_id).should.equal true @rClient.srem.calledWith("users_in_project:#{@project_id}", @user_id).should.equal true
done() done()
it "should delete the connected_user string", (done)-> it "should delete the connected_user string", (done)->
@ConnectedUsersManager.marksUserAsDisconnected @project_id, @user_id, (err)=> @ConnectedUsersManager.markUserAsDisconnected @project_id, @user_id, (err)=>
@rClient.del.calledWith("connected_user:#{@project_id}:#{@user_id}").should.equal true @rClient.del.calledWith("connected_user:#{@project_id}:#{@user_id}").should.equal true
done() done()

View file

@ -54,7 +54,7 @@ describe "EditorController", ->
@ProjectDeleter = @ProjectDeleter =
deleteProject: sinon.stub() deleteProject: sinon.stub()
@ConnectedUsersManager = @ConnectedUsersManager =
marksUserAsDisconnected:sinon.stub() markUserAsDisconnected:sinon.stub()
markUserAsConnected:sinon.stub() markUserAsConnected:sinon.stub()
@EditorController = SandboxedModule.require modulePath, requires: @EditorController = SandboxedModule.require modulePath, requires:
@ -156,7 +156,7 @@ describe "EditorController", ->
@EditorRealTimeController.emitToRoom = sinon.stub() @EditorRealTimeController.emitToRoom = sinon.stub()
@EditorController.flushProjectIfEmpty = sinon.stub() @EditorController.flushProjectIfEmpty = sinon.stub()
@EditorController.leaveProject @client, @user @EditorController.leaveProject @client, @user
@ConnectedUsersManager.marksUserAsDisconnected.callsArgWith(2) @ConnectedUsersManager.markUserAsDisconnected.callsArgWith(2)
it "should call the flush project if empty function", -> it "should call the flush project if empty function", ->
@EditorController.flushProjectIfEmpty @EditorController.flushProjectIfEmpty
@ -172,7 +172,7 @@ describe "EditorController", ->
@EditorRealTimeController.emitToRoom.calledWith(@project_id, "ConnectedUsers.userDissconected", @user).should.equal true @EditorRealTimeController.emitToRoom.calledWith(@project_id, "ConnectedUsers.userDissconected", @user).should.equal true
it "should mark the user as connected with the ConnectedUsersManager", -> it "should mark the user as connected with the ConnectedUsersManager", ->
@ConnectedUsersManager.marksUserAsDisconnected.calledWith(@project_id, @user_id).should.equal true @ConnectedUsersManager.markUserAsDisconnected.calledWith(@project_id, @user_id).should.equal true
describe "joinDoc", -> describe "joinDoc", ->