moved renameEntity from collab manager to editor controller

This commit is contained in:
Henry Oswald 2014-04-04 16:35:02 +01:00
parent 3983e77b73
commit 88e47bbe12
4 changed files with 34 additions and 10 deletions

View file

@ -242,6 +242,17 @@ module.exports = EditorController =
logger.log project_id:project_id, "recived message to delete project"
ProjectHandler.deleteProject project_id, callback
renameEntity: (project_id, entity_id, entityType, newName, callback)->
newName = sanitize.escape(newName)
Metrics.inc "editor.rename-entity"
logger.log entity_id:entity_id, entity_id:entity_id, entity_id:entity_id, "reciving new name for entity for project"
ProjectHandler.renameEntity project_id, entity_id, entityType, newName, =>
if newName.length > 0
EditorRealTimeController.emitToRoom project_id, 'reciveEntityRename', entity_id, newName
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,15 +15,6 @@ EditorRealTimeController = require('../Features/Editor/EditorRealTimeController'
module.exports = class CollaberationManager
constructor: (@io)->
renameEntity: (project_id, entity_id, entityType, newName, callback)->
newName = sanitize.escape(newName)
metrics.inc "editor.rename-entity"
logger.log entity_id:entity_id, entity_id:entity_id, entity_id:entity_id, "reciving new name for entity for project"
projectHandler.renameEntity project_id, entity_id, entityType, newName, =>
if newName.length > 0
EditorRealTimeController.emitToRoom project_id, 'reciveEntityRename', entity_id, newName
callback?()
moveEntity: (project_id, entity_id, folder_id, entityType, callback)->
metrics.inc "editor.move-entity"
projectEntityHandler.moveEntity project_id, entity_id, folder_id, entityType, =>

View file

@ -291,7 +291,7 @@ module.exports = class Router
client.on 'renameEntity', (entity_id, entityType, newName, callback)->
AuthorizationManager.ensureClientCanEditProject client, (error, project_id) =>
collaberationManager.renameEntity(project_id, entity_id, entityType, newName, callback)
EditorController.renameEntity(project_id, entity_id, entityType, newName, callback)
client.on 'moveEntity', (entity_id, folder_id, entityType, callback)->
AuthorizationManager.ensureClientCanEditProject client, (error, project_id) =>

View file

@ -621,3 +621,25 @@ describe "EditorController", ->
@ProjectHandler::deleteProject.calledWith(@project_id).should.equal true
done()
describe "renameEntity", ->
beforeEach ->
@err = "errro"
@entity_id = "entity_id_here"
@entityType = "doc"
@newName = "bobsfile.tex"
@ProjectHandler::renameEntity = sinon.stub().callsArgWith(4, @err)
@EditorRealTimeController.emitToRoom = sinon.stub()
it "should call the project handler", (done)->
@EditorController.renameEntity @project_id, @entity_id, @entityType, @newName, =>
@ProjectHandler::renameEntity.calledWith(@project_id, @entity_id, @entityType, @newName).should.equal true
done()
it "should emit the update to the room", (done)->
@EditorController.renameEntity @project_id, @entity_id, @entityType, @newName, =>
@EditorRealTimeController.emitToRoom.calledWith(@project_id, 'reciveEntityRename', @entity_id, @newName).should.equal true
done()