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
], 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"
async.series [
(cb)->

View file

@ -68,7 +68,7 @@ module.exports = EditorController =
return if error? or !project_id?
EditorRealTimeController.emitToRoom(project_id, "clientTracking.clientDisconnected", client.id)
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"
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
done()
describe "marksUserAsDisconnected", ->
describe "markUserAsDisconnected", ->
beforeEach ->
@rClient.srem.callsArgWith(2)
@rClient.del.callsArgWith(1)
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
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
done()

View file

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