diff --git a/services/web/app/coffee/Features/Project/ProjectDuplicator.coffee b/services/web/app/coffee/Features/Project/ProjectDuplicator.coffee index f9aa18b74e..692abe4ef7 100644 --- a/services/web/app/coffee/Features/Project/ProjectDuplicator.coffee +++ b/services/web/app/coffee/Features/Project/ProjectDuplicator.coffee @@ -50,7 +50,7 @@ module.exports = copyFolder = (folder, desFolder, callback)-> jobs = folder.folders.map (childFolder)-> return (callback)-> - projectEntityHandler.addFolder newProject, desFolder._id, childFolder.name, (err, newFolder)-> + projectEntityHandler.addFolder newProject._id, desFolder._id, childFolder.name, (err, newFolder)-> copyFolder childFolder, newFolder, callback jobs.push (cb)-> copyDocs folder, desFolder, cb diff --git a/services/web/app/coffee/Features/Project/ProjectEntityHandler.coffee b/services/web/app/coffee/Features/Project/ProjectEntityHandler.coffee index cfdb079cb3..e2dca8baf1 100644 --- a/services/web/app/coffee/Features/Project/ProjectEntityHandler.coffee +++ b/services/web/app/coffee/Features/Project/ProjectEntityHandler.coffee @@ -236,12 +236,12 @@ module.exports = ProjectEntityHandler = !folder.filterOut callback(null, folders, lastFolder) - addFolder: (project_or_id, parentFolder_id, folderName, callback) -> + addFolder: (project_id, parentFolder_id, folderName, callback) -> folder = new Folder name: folderName - Project.getProject project_or_id, "", (err, project) -> + ProjectGetter.getProjectWithOnlyFolders project_id, (err, project)=> return callback(err) if err? confirmFolder project, parentFolder_id, (parentFolder_id)=> - logger.log project: project_or_id, parentFolder_id:parentFolder_id, folderName:folderName, "new folder added" + logger.log project: project_id, parentFolder_id:parentFolder_id, folderName:folderName, "new folder added" Project.putElement project._id, parentFolder_id, folder, "folder", (err, result)=> if callback? callback(err, folder, parentFolder_id) diff --git a/services/web/test/UnitTests/coffee/Project/ProjectDuplicatorTests.coffee b/services/web/test/UnitTests/coffee/Project/ProjectDuplicatorTests.coffee index fa7be3c94b..05427f3011 100644 --- a/services/web/test/UnitTests/coffee/Project/ProjectDuplicatorTests.coffee +++ b/services/web/test/UnitTests/coffee/Project/ProjectDuplicatorTests.coffee @@ -124,8 +124,8 @@ describe 'ProjectDuplicator', -> it 'should copy all the folders', (done)-> @duplicator.duplicate @owner, @project_id, "", (err, newProject)=> - @entityHandler.addFolder.calledWith(@stubbedNewProject, @stubbedNewProject.rootFolder[0]._id, @level1folder.name).should.equal true - @entityHandler.addFolder.calledWith(@stubbedNewProject, @newFolder._id, @level2folder.name).should.equal true + @entityHandler.addFolder.calledWith(@stubbedNewProject._id, @stubbedNewProject.rootFolder[0]._id, @level1folder.name).should.equal true + @entityHandler.addFolder.calledWith(@stubbedNewProject._id, @newFolder._id, @level2folder.name).should.equal true @entityHandler.addFolder.callCount.should.equal 2 done()