Kaynağa Gözat

moved setRootDoc from collab manager to editor controller

Henry Oswald 12 yıl önce
ebeveyn
işleme
90eac4d52c

+ 6 - 0
services/web/app/coffee/Features/Editor/EditorController.coffee

@@ -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"

+ 0 - 7
services/web/app/coffee/managers/CollaberationManager.coffee

@@ -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

+ 1 - 1
services/web/app/coffee/router.coffee

@@ -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) =>

+ 17 - 0
services/web/test/UnitTests/coffee/Editor/EditorControllerTests.coffee

@@ -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()