mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-02 10:20:49 -05:00
pass userId into ProjectEntityHandler.replaceFile
This commit is contained in:
parent
088ce33cbc
commit
08891c7a7f
4 changed files with 11 additions and 11 deletions
|
@ -60,7 +60,7 @@ module.exports = EditorController =
|
||||||
callback(err, fileRef)
|
callback(err, fileRef)
|
||||||
|
|
||||||
replaceFile: (project_id, file_id, fsPath, source, callback = (error) ->)->
|
replaceFile: (project_id, file_id, fsPath, source, callback = (error) ->)->
|
||||||
ProjectEntityHandler.replaceFile project_id, file_id, fsPath, callback
|
ProjectEntityHandler.replaceFile project_id, file_id, fsPath, null, callback
|
||||||
|
|
||||||
addFolder : (project_id, folder_id, folderName, source, callback = (error, folder)->)->
|
addFolder : (project_id, folder_id, folderName, source, callback = (error, folder)->)->
|
||||||
LockManager.getLock project_id, (err)->
|
LockManager.getLock project_id, (err)->
|
||||||
|
|
|
@ -222,7 +222,7 @@ module.exports = ProjectEntityHandler =
|
||||||
return callback(error) if error?
|
return callback(error) if error?
|
||||||
callback null, fileRef, folder_id
|
callback null, fileRef, folder_id
|
||||||
|
|
||||||
replaceFile: (project_id, file_id, fsPath, callback)->
|
replaceFile: (project_id, file_id, fsPath, userId, callback)->
|
||||||
self = ProjectEntityHandler
|
self = ProjectEntityHandler
|
||||||
ProjectGetter.getProject project_id, {name:true}, (err, project) ->
|
ProjectGetter.getProject project_id, {name:true}, (err, project) ->
|
||||||
return callback(err) if err?
|
return callback(err) if err?
|
||||||
|
@ -251,7 +251,7 @@ module.exports = ProjectEntityHandler =
|
||||||
return callback(err) if err?
|
return callback(err) if err?
|
||||||
self.getAllEntitiesFromProject newProject, (err, newDocs, newFiles) =>
|
self.getAllEntitiesFromProject newProject, (err, newDocs, newFiles) =>
|
||||||
return callback(err) if err?
|
return callback(err) if err?
|
||||||
DocumentUpdaterHandler.updateProjectStructure project_id, null, oldDocs, newDocs, oldFiles, newFiles, callback
|
DocumentUpdaterHandler.updateProjectStructure project_id, userId, oldDocs, newDocs, oldFiles, newFiles, callback
|
||||||
|
|
||||||
copyFileFromExistingProjectWithProject: (project, folder_id, originalProject_id, origonalFileRef, callback = (error, fileRef, folder_id) ->)->
|
copyFileFromExistingProjectWithProject: (project, folder_id, originalProject_id, origonalFileRef, callback = (error, fileRef, folder_id) ->)->
|
||||||
project_id = project._id
|
project_id = project._id
|
||||||
|
|
|
@ -253,7 +253,7 @@ describe "EditorController", ->
|
||||||
@fsPath = "/folder/file.png"
|
@fsPath = "/folder/file.png"
|
||||||
|
|
||||||
it 'should send the replace file message to the editor controller', (done)->
|
it 'should send the replace file message to the editor controller', (done)->
|
||||||
@ProjectEntityHandler.replaceFile = sinon.stub().callsArgWith(3)
|
@ProjectEntityHandler.replaceFile = sinon.stub().callsArgWith(4)
|
||||||
@EditorController.replaceFile @project_id, @file_id, @fsPath, @source, =>
|
@EditorController.replaceFile @project_id, @file_id, @fsPath, @source, =>
|
||||||
@ProjectEntityHandler.replaceFile.calledWith(@project_id, @file_id, @fsPath).should.equal true
|
@ProjectEntityHandler.replaceFile.calledWith(@project_id, @file_id, @fsPath).should.equal true
|
||||||
done()
|
done()
|
||||||
|
|
|
@ -603,14 +603,14 @@ describe 'ProjectEntityHandler', ->
|
||||||
@ProjectGetter.getProject = sinon.stub().callsArgWith(2, null, @project)
|
@ProjectGetter.getProject = sinon.stub().callsArgWith(2, null, @project)
|
||||||
|
|
||||||
it 'should find the file', (done)->
|
it 'should find the file', (done)->
|
||||||
@ProjectEntityHandler.replaceFile project_id, @file_id, @fsPath, =>
|
@ProjectEntityHandler.replaceFile project_id, @file_id, @fsPath, userId, =>
|
||||||
@projectLocator.findElement
|
@projectLocator.findElement
|
||||||
.calledWith({element_id:@file_id, type:"file", project: @project})
|
.calledWith({element_id:@file_id, type:"file", project: @project})
|
||||||
.should.equal true
|
.should.equal true
|
||||||
done()
|
done()
|
||||||
|
|
||||||
it 'should tell the file store handler to upload the file from disk', (done)->
|
it 'should tell the file store handler to upload the file from disk', (done)->
|
||||||
@ProjectEntityHandler.replaceFile project_id, @file_id, @fsPath, =>
|
@ProjectEntityHandler.replaceFile project_id, @file_id, @fsPath, userId, =>
|
||||||
@FileStoreHandler.uploadFileFromDisk.calledWith(project_id, @file_id, @fsPath).should.equal true
|
@FileStoreHandler.uploadFileFromDisk.calledWith(project_id, @file_id, @fsPath).should.equal true
|
||||||
done()
|
done()
|
||||||
|
|
||||||
|
@ -623,7 +623,7 @@ describe 'ProjectEntityHandler', ->
|
||||||
options.rev.should.equal @fileRef.rev + 1
|
options.rev.should.equal @fileRef.rev + 1
|
||||||
done()
|
done()
|
||||||
|
|
||||||
@ProjectEntityHandler.replaceFile project_id, @file_id, @fsPath, =>
|
@ProjectEntityHandler.replaceFile project_id, @file_id, @fsPath, userId, =>
|
||||||
|
|
||||||
it 'should inc the rev id', (done)->
|
it 'should inc the rev id', (done)->
|
||||||
@ProjectModel.findOneAndUpdate = (conditions, update, options, callback)=>
|
@ProjectModel.findOneAndUpdate = (conditions, update, options, callback)=>
|
||||||
|
@ -631,7 +631,7 @@ describe 'ProjectEntityHandler', ->
|
||||||
update.$inc["#{@filePaths.mongo}.rev"].should.equal 1
|
update.$inc["#{@filePaths.mongo}.rev"].should.equal 1
|
||||||
done()
|
done()
|
||||||
|
|
||||||
@ProjectEntityHandler.replaceFile project_id, @file_id, @fsPath, =>
|
@ProjectEntityHandler.replaceFile project_id, @file_id, @fsPath, userId, =>
|
||||||
|
|
||||||
it 'should update the created at date', (done)->
|
it 'should update the created at date', (done)->
|
||||||
d = new Date()
|
d = new Date()
|
||||||
|
@ -641,12 +641,12 @@ describe 'ProjectEntityHandler', ->
|
||||||
differenceInMs.should.be.below(20)
|
differenceInMs.should.be.below(20)
|
||||||
done()
|
done()
|
||||||
|
|
||||||
@ProjectEntityHandler.replaceFile project_id, @file_id, @fsPath, =>
|
@ProjectEntityHandler.replaceFile project_id, @file_id, @fsPath, userId, =>
|
||||||
|
|
||||||
it "should should send the old and new project structure to the doc updater", (done) ->
|
it "should should send the old and new project structure to the doc updater", (done) ->
|
||||||
@ProjectEntityHandler.replaceFile project_id, @file_id, @fsPath, =>
|
@ProjectEntityHandler.replaceFile project_id, @file_id, @fsPath, userId, =>
|
||||||
@documentUpdaterHandler.updateProjectStructure
|
@documentUpdaterHandler.updateProjectStructure
|
||||||
.calledWith(project_id, null, [], [], @oldFiles, @newFiles)
|
.calledWith(project_id, userId, [], [], @oldFiles, @newFiles)
|
||||||
.should.equal true
|
.should.equal true
|
||||||
done()
|
done()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue