moved setRootDoc from collab manager to editor controller

This commit is contained in:
Henry Oswald 2014-04-04 16:59:45 +01:00
parent 7c10b5cd24
commit 90eac4d52c
4 changed files with 24 additions and 8 deletions

View file

@ -269,6 +269,12 @@ module.exports = EditorController =
EditorRealTimeController.emitToRoom project_id, 'publicAccessLevelUpdated', newAccessLevel
callback?()
setRootDoc: (project_id, newRootDocID, callback)->
ProjectEntityHandler.setRootDoc project_id, newRootDocID, () =>
EditorRealTimeController.emitToRoom project_id, 'rootDocUpdated', newRootDocID
callback?()
p:
notifyProjectUsersOfNewFolder: (project_id, folder_id, folder, callback = (error)->)->
logger.log project_id:project_id, folder:folder, parentFolder_id:folder_id, "sending newly created folder out to users"

View file

@ -15,18 +15,11 @@ EditorRealTimeController = require('../Features/Editor/EditorRealTimeController'
module.exports = class CollaberationManager
constructor: (@io)->
distributMessage: (project_id, client, message)->
message = sanitize.escape(message)
metrics.inc "editor.instant-message"
client.get "first_name", (err, first_name)=>
EditorRealTimeController.emitToRoom project_id, 'reciveNewMessage', first_name, message
setRootDoc: (project_id, newRootDocID, callback)->
projectEntityHandler.setRootDoc project_id, newRootDocID, () =>
EditorRealTimeController.emitToRoom project_id, 'rootDocUpdated', newRootDocID
callback?()
takeVersionSnapShot : (project_id, message, callback)->
versioningApiHandler.takeVersionSnapshot project_id, message, callback

View file

@ -307,7 +307,7 @@ module.exports = class Router
client.on 'setRootDoc', (newRootDocID, callback)->
AuthorizationManager.ensureClientCanEditProject client, (error, project_id) =>
collaberationManager.setRootDoc(project_id, newRootDocID, callback)
EditorController.setRootDoc(project_id, newRootDocID, callback)
client.on 'deleteProject', (callback)->
AuthorizationManager.ensureClientCanAdminProject client, (error, project_id) =>

View file

@ -703,3 +703,20 @@ describe "EditorController", ->
@EditorRealTimeController.emitToRoom.calledWith(@project_id, 'publicAccessLevelUpdated', @newAccessLevel).should.equal true
done()
describe "setRootDoc", ->
beforeEach ->
@err = "errro"
@newRootDocID = "21312321321"
@ProjectEntityHandler.setRootDoc = sinon.stub().callsArgWith(2, @err)
@EditorRealTimeController.emitToRoom = sinon.stub()
it "should call the ProjectEntityHandler", (done)->
@EditorController.setRootDoc @project_id, @newRootDocID, =>
@ProjectEntityHandler.setRootDoc.calledWith(@project_id, @newRootDocID).should.equal true
done()
it "should emit the update to the room", (done)->
@EditorController.setRootDoc @project_id, @newRootDocID, =>
@EditorRealTimeController.emitToRoom.calledWith(@project_id, 'rootDocUpdated', @newRootDocID).should.equal true
done()