From 39c7010d72d54414329b403b9693fbc5423bc4cb Mon Sep 17 00:00:00 2001 From: Henry Oswald Date: Mon, 29 Feb 2016 22:51:46 +0000 Subject: [PATCH] fixed broken tests --- .../Features/Project/ProjectEntityHandler.coffee | 7 ++++--- .../coffee/Project/ProjectDuplicatorTests.coffee | 10 +++++----- .../coffee/Project/ProjectEntityHandlerTests.coffee | 11 +++++------ 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/services/web/app/coffee/Features/Project/ProjectEntityHandler.coffee b/services/web/app/coffee/Features/Project/ProjectEntityHandler.coffee index 53f7209ca7..99d483d9eb 100644 --- a/services/web/app/coffee/Features/Project/ProjectEntityHandler.coffee +++ b/services/web/app/coffee/Features/Project/ProjectEntityHandler.coffee @@ -120,7 +120,7 @@ module.exports = ProjectEntityHandler = DocstoreManager.updateDoc project._id.toString(), doc._id.toString(), docLines, (err, modified, rev) -> return callback(err) if err? - ProjectEntityHandler._putElement project._id, folder_id, doc, "doc", (err, result)=> + ProjectEntityHandler._putElement project, folder_id, doc, "doc", (err, result)=> return callback(err) if err? tpdsUpdateSender.addDoc { project_id: project?._id, @@ -194,10 +194,11 @@ module.exports = ProjectEntityHandler = FileStoreHandler.copyFile originalProject_id, origonalFileRef._id, project._id, fileRef._id, (err)-> if err? logger.err err:err, project_id:project._id, folder_id:folder_id, originalProject_id:originalProject_id, origonalFileRef:origonalFileRef, "error coping file in s3" + return callback(err) ProjectEntityHandler._putElement project._id, folder_id, fileRef, "file", (err, result)=> if err? logger.err err:err, project_id:project._id, folder_id:folder_id, "error putting element as part of copy" - return callback() + return callback(err) tpdsUpdateSender.addFile {project_id:project._id, file_id:fileRef._id, path:result?.path?.fileSystem, rev:fileRef.rev, project_name:project.name}, (error) -> callback(error, fileRef, folder_id) @@ -463,7 +464,7 @@ module.exports = ProjectEntityHandler = if !element? e = new Error("no element passed to be inserted") - logger.err project_id:project_id, folder_id:folder_id, element:element, type:type, "failed trying to insert element as it was null" + logger.err project_id:project_or_id, folder_id:folder_id, element:element, type:type, "failed trying to insert element as it was null" return callback(e) type = sanitizeTypeOfElement type ProjectGetter.getProject project_or_id, {rootFolder:true}, (err, project)=> diff --git a/services/web/test/UnitTests/coffee/Project/ProjectDuplicatorTests.coffee b/services/web/test/UnitTests/coffee/Project/ProjectDuplicatorTests.coffee index 586b997fde..175c3cfe48 100644 --- a/services/web/test/UnitTests/coffee/Project/ProjectDuplicatorTests.coffee +++ b/services/web/test/UnitTests/coffee/Project/ProjectDuplicatorTests.coffee @@ -128,17 +128,17 @@ describe 'ProjectDuplicator', -> it 'should copy all the folders', (done)-> @duplicator.duplicate @owner, @project_id, "", (err, newProject)=> - @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.calledWith(@stubbedNewProject, @stubbedNewProject.rootFolder[0]._id, @level1folder.name).should.equal true + @entityHandler.addFolder.calledWith(@stubbedNewProject, @newFolder._id, @level2folder.name).should.equal true @entityHandler.addFolder.callCount.should.equal 2 done() it 'should copy all the docs', (done)-> @duplicator.duplicate @owner, @project_id, "", (err, newProject)=> @DocstoreManager.getAllDocs.calledWith(@project_id).should.equal true - @entityHandler.addDoc.calledWith(@stubbedNewProject._id, @stubbedNewProject.rootFolder[0]._id, @doc0.name, @doc0_lines).should.equal true - @entityHandler.addDoc.calledWith(@stubbedNewProject._id, @newFolder._id, @doc1.name, @doc1_lines).should.equal true - @entityHandler.addDoc.calledWith(@stubbedNewProject._id, @newFolder._id, @doc2.name, @doc2_lines).should.equal true + @entityHandler.addDoc.calledWith(@stubbedNewProject, @stubbedNewProject.rootFolder[0]._id, @doc0.name, @doc0_lines).should.equal true + @entityHandler.addDoc.calledWith(@stubbedNewProject, @newFolder._id, @doc1.name, @doc1_lines).should.equal true + @entityHandler.addDoc.calledWith(@stubbedNewProject, @newFolder._id, @doc2.name, @doc2_lines).should.equal true done() it 'should copy all the files', (done)-> diff --git a/services/web/test/UnitTests/coffee/Project/ProjectEntityHandlerTests.coffee b/services/web/test/UnitTests/coffee/Project/ProjectEntityHandlerTests.coffee index 39e7b5bcfc..9c7ef8ea88 100644 --- a/services/web/test/UnitTests/coffee/Project/ProjectEntityHandlerTests.coffee +++ b/services/web/test/UnitTests/coffee/Project/ProjectEntityHandlerTests.coffee @@ -59,6 +59,7 @@ describe 'ProjectEntityHandler', -> @ProjectModel.getProject = (project_id, fields, callback)=> callback(null, @project) @ProjectGetter = getProjectWithOnlyFolders : (project_id, callback)=> callback(null, @project) + getProjectWithoutDocLines : (project_id, callback)=> callback(null, @project) getProject:sinon.stub() @projectUpdater = markAsUpdated:sinon.stub() @projectLocator = @@ -426,9 +427,7 @@ describe 'ProjectEntityHandler', -> expect(@doc.lines).to.be.undefined it 'should call put element', -> - @ProjectEntityHandler._putElement - .calledWith(project_id, folder_id, @doc) - .should.equal true + @ProjectEntityHandler._putElement.calledWith(@project, folder_id, @doc).should.equal true it 'should return doc and parent folder', -> @callback.calledWith(null, @doc, folder_id).should.equal true @@ -868,13 +867,13 @@ describe 'ProjectEntityHandler', -> @ProjectModel.update.calledWith({_id : @project_id}, {$unset : {rootDoc_id: true}}) .should.equal true - describe 'copying file', -> + describe 'copyFileFromExistingProject', -> fileName = "something.jpg" filePath = "dumpFolder/somewhere/image.jpeg" oldProject_id = "123kljadas" oldFileRef = {name:fileName, _id:"oldFileRef"} beforeEach -> - @ProjectModel.getProject = (project_id, fields, callback)=> callback(null, {name:@project.name, _id:@project._id}) + @ProjectGetter.getProject = (project_id, fields, callback)=> callback(null, {name:@project.name, _id:@project._id}) @ProjectEntityHandler._putElement = sinon.stub().callsArgWith(4, null, {path:{fileSystem:"somehintg"}}) @@ -1041,7 +1040,7 @@ describe 'ProjectEntityHandler', -> it "should use the correct mongo path", (done)-> @ProjectEntityHandler._putElement @project_id, @folder._id, @doc, "docs", (err)=> - @ProjectModel.update.args[0][0]._id.should.equal @project_id + @ProjectModel.update.args[0][0]._id.should.equal @project._id assert.deepEqual @ProjectModel.update.args[0][1].$push[@path.mongo+".docs"], @doc done()