pass user_id into EditorController.replaceFile

This commit is contained in:
Hayden Faulds
2017-12-04 09:42:09 +00:00
parent 08891c7a7f
commit feee582368
6 changed files with 10 additions and 10 deletions
@@ -59,8 +59,8 @@ module.exports = EditorController =
EditorRealTimeController.emitToRoom(project_id, 'reciveNewFile', folder_id, fileRef, source) EditorRealTimeController.emitToRoom(project_id, 'reciveNewFile', folder_id, fileRef, source)
callback(err, fileRef) callback(err, fileRef)
replaceFile: (project_id, file_id, fsPath, source, callback = (error) ->)-> replaceFile: (project_id, file_id, fsPath, source, user_id, callback = (error) ->)->
ProjectEntityHandler.replaceFile project_id, file_id, fsPath, null, callback ProjectEntityHandler.replaceFile project_id, file_id, fsPath, user_id, 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)->
@@ -69,7 +69,7 @@ module.exports =
logger.err err:err, project_id:project_id, file_id:file_id, path:path, "error processing file" logger.err err:err, project_id:project_id, file_id:file_id, path:path, "error processing file"
return callback(err) return callback(err)
else if file_id? else if file_id?
editorController.replaceFile project_id, file_id, fsPath, source, finish editorController.replaceFile project_id, file_id, fsPath, source, user_id, finish
else else
editorController.addFile project_id, folder?._id, fileName, fsPath, source, user_id, finish editorController.addFile project_id, folder?._id, fileName, fsPath, source, user_id, finish
@@ -50,7 +50,7 @@ module.exports = FileSystemImportManager =
existingFile = fileRef existingFile = fileRef
break break
if existingFile? if existingFile?
EditorController.replaceFile project_id, existingFile._id, path, "upload", callback EditorController.replaceFile project_id, existingFile._id, path, "upload", user_id, callback
else else
EditorController.addFileWithoutLock project_id, folder_id, name, path, "upload", user_id, callback EditorController.addFileWithoutLock project_id, folder_id, name, path, "upload", user_id, callback
@@ -254,8 +254,8 @@ describe "EditorController", ->
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(4) @ProjectEntityHandler.replaceFile = sinon.stub().callsArgWith(4)
@EditorController.replaceFile @project_id, @file_id, @fsPath, @source, => @EditorController.replaceFile @project_id, @file_id, @fsPath, @source, @user_id, =>
@ProjectEntityHandler.replaceFile.calledWith(@project_id, @file_id, @fsPath).should.equal true @ProjectEntityHandler.replaceFile.calledWith(@project_id, @file_id, @fsPath, @user_id).should.equal true
done() done()
describe 'addFolderWithoutLock :', -> describe 'addFolderWithoutLock :', ->
@@ -115,7 +115,7 @@ describe 'UpdateMerger :', ->
@fileName = "file.png" @fileName = "file.png"
@fsPath = "fs/path.tex" @fsPath = "fs/path.tex"
@editorController.addFile = sinon.stub().callsArg(6) @editorController.addFile = sinon.stub().callsArg(6)
@editorController.replaceFile = sinon.stub().callsArg(4) @editorController.replaceFile = sinon.stub().callsArg(5)
@editorController.deleteEntity = sinon.stub() @editorController.deleteEntity = sinon.stub()
@editorController.mkdirp = sinon.stub().withArgs(@project_id).callsArgWith(2, null, [@folder], @folder) @editorController.mkdirp = sinon.stub().withArgs(@project_id).callsArgWith(2, null, [@folder], @folder)
@updateMerger.p.writeStreamToDisk = sinon.stub().withArgs(@project_id, @file_id, @update).callsArgWith(3, null, @fsPath) @updateMerger.p.writeStreamToDisk = sinon.stub().withArgs(@project_id, @file_id, @update).callsArgWith(3, null, @fsPath)
@@ -123,7 +123,7 @@ describe 'UpdateMerger :', ->
it 'should replace file if the file already exists', (done)-> it 'should replace file if the file already exists', (done)->
@updateMerger.p.processFile @project_id, @file_id, @fsPath, @path, @source, @user_id, => @updateMerger.p.processFile @project_id, @file_id, @fsPath, @path, @source, @user_id, =>
@editorController.addFile.called.should.equal false @editorController.addFile.called.should.equal false
@editorController.replaceFile.calledWith(@project_id, @file_id, @fsPath, @source).should.equal true @editorController.replaceFile.calledWith(@project_id, @file_id, @fsPath, @source, @user_id).should.equal true
done() done()
it 'should call add file if the file does not exist', (done)-> it 'should call add file if the file does not exist', (done)->
@@ -169,7 +169,7 @@ describe "FileSystemImportManager", ->
} }
@FileSystemImportManager._isSafeOnFileSystem = sinon.stub().callsArgWith(1, null, true) @FileSystemImportManager._isSafeOnFileSystem = sinon.stub().callsArgWith(1, null, true)
@ProjectLocator.findElement = sinon.stub().callsArgWith(1, null, @folder) @ProjectLocator.findElement = sinon.stub().callsArgWith(1, null, @folder)
@EditorController.replaceFile = sinon.stub().callsArg(4) @EditorController.replaceFile = sinon.stub().callsArg(5)
@FileSystemImportManager.addFile @user_id, @project_id, @folder_id, @name, @path_on_disk, true, @callback @FileSystemImportManager.addFile @user_id, @project_id, @folder_id, @name, @path_on_disk, true, @callback
it "should look up the folder", -> it "should look up the folder", ->
@@ -178,7 +178,7 @@ describe "FileSystemImportManager", ->
.should.equal true .should.equal true
it "should replace the file", -> it "should replace the file", ->
@EditorController.replaceFile.calledWith(@project_id, @file_id, @path_on_disk, "upload") @EditorController.replaceFile.calledWith(@project_id, @file_id, @path_on_disk, "upload", @user_id)
.should.equal true .should.equal true
describe "addFolder", -> describe "addFolder", ->