pass userId into ProjectEntityHandler.replaceFile

This commit is contained in:
Hayden Faulds 2017-11-24 11:26:43 +00:00
parent 088ce33cbc
commit 08891c7a7f
4 changed files with 11 additions and 11 deletions

View file

@ -60,7 +60,7 @@ module.exports = EditorController =
callback(err, fileRef)
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)->)->
LockManager.getLock project_id, (err)->

View file

@ -222,7 +222,7 @@ module.exports = ProjectEntityHandler =
return callback(error) if error?
callback null, fileRef, folder_id
replaceFile: (project_id, file_id, fsPath, callback)->
replaceFile: (project_id, file_id, fsPath, userId, callback)->
self = ProjectEntityHandler
ProjectGetter.getProject project_id, {name:true}, (err, project) ->
return callback(err) if err?
@ -251,7 +251,7 @@ module.exports = ProjectEntityHandler =
return callback(err) if err?
self.getAllEntitiesFromProject newProject, (err, newDocs, newFiles) =>
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) ->)->
project_id = project._id

View file

@ -253,7 +253,7 @@ describe "EditorController", ->
@fsPath = "/folder/file.png"
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, =>
@ProjectEntityHandler.replaceFile.calledWith(@project_id, @file_id, @fsPath).should.equal true
done()

View file

@ -603,14 +603,14 @@ describe 'ProjectEntityHandler', ->
@ProjectGetter.getProject = sinon.stub().callsArgWith(2, null, @project)
it 'should find the file', (done)->
@ProjectEntityHandler.replaceFile project_id, @file_id, @fsPath, =>
@ProjectEntityHandler.replaceFile project_id, @file_id, @fsPath, userId, =>
@projectLocator.findElement
.calledWith({element_id:@file_id, type:"file", project: @project})
.should.equal true
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
done()
@ -623,7 +623,7 @@ describe 'ProjectEntityHandler', ->
options.rev.should.equal @fileRef.rev + 1
done()
@ProjectEntityHandler.replaceFile project_id, @file_id, @fsPath, =>
@ProjectEntityHandler.replaceFile project_id, @file_id, @fsPath, userId, =>
it 'should inc the rev id', (done)->
@ProjectModel.findOneAndUpdate = (conditions, update, options, callback)=>
@ -631,7 +631,7 @@ describe 'ProjectEntityHandler', ->
update.$inc["#{@filePaths.mongo}.rev"].should.equal 1
done()
@ProjectEntityHandler.replaceFile project_id, @file_id, @fsPath, =>
@ProjectEntityHandler.replaceFile project_id, @file_id, @fsPath, userId, =>
it 'should update the created at date', (done)->
d = new Date()
@ -641,12 +641,12 @@ describe 'ProjectEntityHandler', ->
differenceInMs.should.be.below(20)
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) ->
@ProjectEntityHandler.replaceFile project_id, @file_id, @fsPath, =>
@ProjectEntityHandler.replaceFile project_id, @file_id, @fsPath, userId, =>
@documentUpdaterHandler.updateProjectStructure
.calledWith(project_id, null, [], [], @oldFiles, @newFiles)
.calledWith(project_id, userId, [], [], @oldFiles, @newFiles)
.should.equal true
done()