mirror of
https://github.com/overleaf/overleaf.git
synced 2025-04-09 11:35:47 +00:00
pass userId into ProjectEntiyHandler.copyFileFromExistingProjectWithProject
This commit is contained in:
parent
feee582368
commit
61a1336ec6
4 changed files with 21 additions and 15 deletions
|
@ -31,11 +31,11 @@ module.exports = ProjectDuplicator =
|
|||
|
||||
async.series jobs, callback
|
||||
|
||||
_copyFiles: (newProject, originalProject_id, originalFolder, desFolder, callback)->
|
||||
_copyFiles: (owner_id, newProject, originalProject_id, originalFolder, desFolder, callback)->
|
||||
fileRefs = originalFolder.fileRefs or []
|
||||
jobs = fileRefs.map (file)->
|
||||
return (cb)->
|
||||
projectEntityHandler.copyFileFromExistingProjectWithProject newProject, desFolder._id, originalProject_id, file, cb
|
||||
projectEntityHandler.copyFileFromExistingProjectWithProject newProject, desFolder._id, originalProject_id, file, owner_id, cb
|
||||
async.parallelLimit jobs, 5, callback
|
||||
|
||||
|
||||
|
@ -56,7 +56,7 @@ module.exports = ProjectDuplicator =
|
|||
ProjectDuplicator._copyFolderRecursivly owner_id, newProject_id, originalProject_id, originalRootDoc, childFolder, newFolder, docContents, cb
|
||||
|
||||
jobs.push (cb)->
|
||||
ProjectDuplicator._copyFiles newProject, originalProject_id, originalFolder, desFolder, cb
|
||||
ProjectDuplicator._copyFiles owner_id, newProject, originalProject_id, originalFolder, desFolder, cb
|
||||
jobs.push (cb)->
|
||||
ProjectDuplicator._copyDocs owner_id, newProject, originalRootDoc, originalFolder, desFolder, docContents, cb
|
||||
|
||||
|
|
|
@ -253,7 +253,7 @@ module.exports = ProjectEntityHandler =
|
|||
return callback(err) if err?
|
||||
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, userId, callback = (error, fileRef, folder_id) ->)->
|
||||
project_id = project._id
|
||||
logger.log { project_id, folder_id, originalProject_id, origonalFileRef }, "copying file in s3 with project"
|
||||
return callback(err) if err?
|
||||
|
@ -277,7 +277,7 @@ module.exports = ProjectEntityHandler =
|
|||
file: fileRef
|
||||
path: result?.path?.fileSystem
|
||||
url: fileStoreUrl
|
||||
DocumentUpdaterHandler.updateProjectStructure project_id, null, [], [], [], [newFile], (error) ->
|
||||
DocumentUpdaterHandler.updateProjectStructure project_id, userId, [], [], [], [newFile], (error) ->
|
||||
return callback(error) if error?
|
||||
callback null, fileRef, folder_id
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ describe 'ProjectDuplicator', ->
|
|||
setCompiler : sinon.stub()
|
||||
@entityHandler =
|
||||
addDocWithProject: sinon.stub().callsArgWith(5, null, {name:"somDoc"})
|
||||
copyFileFromExistingProjectWithProject: sinon.stub().callsArgWith(4)
|
||||
copyFileFromExistingProjectWithProject: sinon.stub().callsArgWith(5)
|
||||
setRootDoc: sinon.stub()
|
||||
addFolderWithProject: sinon.stub().callsArgWith(3, null, @newFolder)
|
||||
|
||||
|
@ -152,7 +152,13 @@ describe 'ProjectDuplicator', ->
|
|||
|
||||
it 'should copy all the files', (done)->
|
||||
@duplicator.duplicate @owner, @old_project_id, "", (err, newProject)=>
|
||||
@entityHandler.copyFileFromExistingProjectWithProject.calledWith(@stubbedNewProject, @stubbedNewProject.rootFolder[0]._id, @project._id, @rootFolder.fileRefs[0]).should.equal true
|
||||
@entityHandler.copyFileFromExistingProjectWithProject.calledWith(@stubbedNewProject, @newFolder._id, @project._id, @level1folder.fileRefs[0]).should.equal true
|
||||
@entityHandler.copyFileFromExistingProjectWithProject.calledWith(@stubbedNewProject, @newFolder._id, @project._id, @level2folder.fileRefs[0]).should.equal true
|
||||
@entityHandler.copyFileFromExistingProjectWithProject
|
||||
.calledWith(@stubbedNewProject, @stubbedNewProject.rootFolder[0]._id, @project._id, @rootFolder.fileRefs[0], @owner._id)
|
||||
.should.equal true
|
||||
@entityHandler.copyFileFromExistingProjectWithProject
|
||||
.calledWith(@stubbedNewProject, @newFolder._id, @project._id, @level1folder.fileRefs[0], @owner._id)
|
||||
.should.equal true
|
||||
@entityHandler.copyFileFromExistingProjectWithProject
|
||||
.calledWith(@stubbedNewProject, @newFolder._id, @project._id, @level2folder.fileRefs[0], @owner._id)
|
||||
.should.equal true
|
||||
done()
|
||||
|
|
|
@ -994,7 +994,7 @@ describe 'ProjectEntityHandler', ->
|
|||
|
||||
it 'should copy the file in FileStoreHandler', (done)->
|
||||
@ProjectEntityHandler._putElement = sinon.stub().callsArgWith(4, null, {path:{fileSystem:"somehintg"}})
|
||||
@ProjectEntityHandler.copyFileFromExistingProjectWithProject @project, folder_id, oldProject_id, oldFileRef, (err, fileRef, parentFolder)=>
|
||||
@ProjectEntityHandler.copyFileFromExistingProjectWithProject @project, folder_id, oldProject_id, oldFileRef, userId, (err, fileRef, parentFolder)=>
|
||||
@FileStoreHandler.copyFile.calledWith(oldProject_id, oldFileRef._id, project_id, fileRef._id).should.equal true
|
||||
done()
|
||||
|
||||
|
@ -1006,10 +1006,10 @@ describe 'ProjectEntityHandler', ->
|
|||
passedType.should.equal 'file'
|
||||
done()
|
||||
|
||||
@ProjectEntityHandler.copyFileFromExistingProjectWithProject @project, folder_id, oldProject_id, oldFileRef, (err, fileRef, parentFolder)->
|
||||
@ProjectEntityHandler.copyFileFromExistingProjectWithProject @project, folder_id, oldProject_id, oldFileRef, userId, (err, fileRef, parentFolder)->
|
||||
|
||||
it 'should return doc and parent folder', (done)->
|
||||
@ProjectEntityHandler.copyFileFromExistingProjectWithProject @project, folder_id, oldProject_id, oldFileRef, (err, fileRef, parentFolder)->
|
||||
@ProjectEntityHandler.copyFileFromExistingProjectWithProject @project, folder_id, oldProject_id, oldFileRef, userId, (err, fileRef, parentFolder)->
|
||||
parentFolder.should.equal folder_id
|
||||
fileRef.name.should.equal fileName
|
||||
done()
|
||||
|
@ -1029,12 +1029,12 @@ describe 'ProjectEntityHandler', ->
|
|||
options.rev.should.equal 0
|
||||
done()
|
||||
|
||||
@ProjectEntityHandler.copyFileFromExistingProjectWithProject @project, folder_id, oldProject_id, oldFileRef, (err, fileRef, parentFolder)->
|
||||
@ProjectEntityHandler.copyFileFromExistingProjectWithProject @project, folder_id, oldProject_id, oldFileRef, userId, (err, fileRef, parentFolder)->
|
||||
|
||||
it "should should send the change in project structure to the doc updater", (done) ->
|
||||
@documentUpdaterHandler.updateProjectStructure = (passed_project_id, passed_user_id, oldDocs, newDocs, oldFiles, newFiles) =>
|
||||
passed_project_id.should.equal project_id
|
||||
#passed_user_id.should.equal userId
|
||||
passed_user_id.should.equal userId
|
||||
newFiles.length.should.equal 1
|
||||
newFile = newFiles[0]
|
||||
newFile.file.name.should.equal fileName
|
||||
|
@ -1042,7 +1042,7 @@ describe 'ProjectEntityHandler', ->
|
|||
newFile.url.should.equal @fileUrl
|
||||
done()
|
||||
|
||||
@ProjectEntityHandler.copyFileFromExistingProjectWithProject @project, folder_id, oldProject_id, oldFileRef, (err, fileRef, parentFolder)->
|
||||
@ProjectEntityHandler.copyFileFromExistingProjectWithProject @project, folder_id, oldProject_id, oldFileRef, userId, (err, fileRef, parentFolder)->
|
||||
|
||||
describe "renameEntity", ->
|
||||
beforeEach ->
|
||||
|
|
Loading…
Add table
Reference in a new issue