mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
pass userId to ProjectEntityHandler.deleteEntity
This commit is contained in:
parent
2ac74b9adc
commit
5f6686ed3b
4 changed files with 23 additions and 26 deletions
|
@ -110,14 +110,14 @@ module.exports = EditorController =
|
|||
if err?
|
||||
logger.err err:err, project_id:project_id, "could not get lock to deleteEntity"
|
||||
return callback(err)
|
||||
EditorController.deleteEntityWithoutLock project_id, entity_id, entityType, source, (err)->
|
||||
EditorController.deleteEntityWithoutLock project_id, entity_id, entityType, source, null, (err)->
|
||||
LockManager.releaseLock project_id, ()->
|
||||
callback(err)
|
||||
|
||||
deleteEntityWithoutLock: (project_id, entity_id, entityType, source, callback)->
|
||||
deleteEntityWithoutLock: (project_id, entity_id, entityType, source, userId, callback)->
|
||||
logger.log {project_id, entity_id, entityType, source}, "start delete process of entity"
|
||||
Metrics.inc "editor.delete-entity"
|
||||
ProjectEntityHandler.deleteEntity project_id, entity_id, entityType, (err)->
|
||||
ProjectEntityHandler.deleteEntity project_id, entity_id, entityType, userId, (err)->
|
||||
if err?
|
||||
logger.err err:err, project_id:project_id, entity_id:entity_id, entityType:entityType, "error deleting entity"
|
||||
return callback(err)
|
||||
|
|
|
@ -412,7 +412,7 @@ module.exports = ProjectEntityHandler =
|
|||
callback()
|
||||
|
||||
|
||||
deleteEntity: (project_id, entity_id, entityType, callback = (error) ->)->
|
||||
deleteEntity: (project_id, entity_id, entityType, userId, callback = (error) ->)->
|
||||
self = @
|
||||
logger.log entity_id:entity_id, entityType:entityType, project_id:project_id, "deleting project entity"
|
||||
if !entityType?
|
||||
|
@ -423,7 +423,7 @@ module.exports = ProjectEntityHandler =
|
|||
return callback(error) if error?
|
||||
projectLocator.findElement {project: project, element_id: entity_id, type: entityType}, (error, entity, path)=>
|
||||
return callback(error) if error?
|
||||
ProjectEntityHandler._cleanUpEntity project, null, entity, entityType, path.fileSystem, (error) ->
|
||||
ProjectEntityHandler._cleanUpEntity project, userId, entity, entityType, path.fileSystem, (error) ->
|
||||
return callback(error) if error?
|
||||
tpdsUpdateSender.deleteEntity project_id:project_id, path:path.fileSystem, project_name:project.name, (error) ->
|
||||
return callback(error) if error?
|
||||
|
|
|
@ -382,11 +382,13 @@ describe "EditorController", ->
|
|||
beforeEach ->
|
||||
@LockManager.getLock.callsArgWith(1)
|
||||
@LockManager.releaseLock.callsArgWith(1)
|
||||
@EditorController.deleteEntityWithoutLock = sinon.stub().callsArgWith(4)
|
||||
@EditorController.deleteEntityWithoutLock = sinon.stub().callsArgWith(5)
|
||||
|
||||
it "should call deleteEntityWithoutLock", (done)->
|
||||
@EditorController.deleteEntity @project_id, @entity_id, @type, @source, =>
|
||||
@EditorController.deleteEntityWithoutLock.calledWith(@project_id, @entity_id, @type, @source).should.equal true
|
||||
@EditorController.deleteEntityWithoutLock
|
||||
.calledWith(@project_id, @entity_id, @type, @source, null)
|
||||
.should.equal true
|
||||
done()
|
||||
|
||||
it "should take the lock", (done)->
|
||||
|
@ -404,30 +406,25 @@ describe "EditorController", ->
|
|||
@EditorController.deleteEntity @project_id, @entity_id, @type, @source, (err)=>
|
||||
expect(err).to.exist
|
||||
err.should.equal "timed out"
|
||||
done()
|
||||
|
||||
|
||||
done()
|
||||
|
||||
describe 'deleteEntityWithoutLock', ->
|
||||
beforeEach ->
|
||||
@ProjectEntityHandler.deleteEntity = (project_id, entity_id, type, callback)-> callback()
|
||||
beforeEach (done) ->
|
||||
@entity_id = "entity_id_here"
|
||||
@type = "doc"
|
||||
@EditorRealTimeController.emitToRoom = sinon.stub()
|
||||
@ProjectEntityHandler.deleteEntity = sinon.stub().callsArg(4)
|
||||
@EditorController.deleteEntityWithoutLock @project_id, @entity_id, @type, @source, @user_id, done
|
||||
|
||||
it 'should delete the folder using the project entity handler', (done)->
|
||||
mock = sinon.mock(@ProjectEntityHandler).expects("deleteEntity").withArgs(@project_id, @entity_id, @type).callsArg(3)
|
||||
it 'should delete the folder using the project entity handler', ->
|
||||
@ProjectEntityHandler.deleteEntity
|
||||
.calledWith(@project_id, @entity_id, @type, @user_id)
|
||||
.should.equal.true
|
||||
|
||||
@EditorController.deleteEntityWithoutLock @project_id, @entity_id, @type, @source, ->
|
||||
mock.verify()
|
||||
done()
|
||||
|
||||
it 'notify users an entity has been deleted', (done)->
|
||||
@EditorController.deleteEntityWithoutLock @project_id, @entity_id, @type, @source, =>
|
||||
@EditorRealTimeController.emitToRoom
|
||||
.calledWith(@project_id, "removeEntity", @entity_id, @source)
|
||||
.should.equal true
|
||||
done()
|
||||
it 'notify users an entity has been deleted', ->
|
||||
@EditorRealTimeController.emitToRoom
|
||||
.calledWith(@project_id, "removeEntity", @entity_id, @source)
|
||||
.should.equal true
|
||||
|
||||
describe "getting a list of project paths", ->
|
||||
|
||||
|
|
|
@ -163,7 +163,7 @@ describe 'ProjectEntityHandler', ->
|
|||
|
||||
describe "deleting from Mongo", ->
|
||||
beforeEach (done) ->
|
||||
@ProjectEntityHandler.deleteEntity project_id, entity_id, @type = 'file', done
|
||||
@ProjectEntityHandler.deleteEntity project_id, entity_id, @type = 'file', userId, done
|
||||
|
||||
it "should retreive the path", ->
|
||||
@projectLocator.findElement.called.should.equal true
|
||||
|
@ -182,7 +182,7 @@ describe 'ProjectEntityHandler', ->
|
|||
|
||||
it "should clean up the entity from the rest of the system", ->
|
||||
@ProjectEntityHandler._cleanUpEntity
|
||||
.calledWith(@project, null, @entity, @type, @path.fileSystem)
|
||||
.calledWith(@project, userId, @entity, @type, @path.fileSystem)
|
||||
.should.equal true
|
||||
|
||||
describe "_cleanUpEntity", ->
|
||||
|
|
Loading…
Reference in a new issue