fixed broken tests

This commit is contained in:
Henry Oswald 2016-02-29 22:51:46 +00:00
parent 76591ebb23
commit 39c7010d72
3 changed files with 14 additions and 14 deletions

View file

@ -120,7 +120,7 @@ module.exports = ProjectEntityHandler =
DocstoreManager.updateDoc project._id.toString(), doc._id.toString(), docLines, (err, modified, rev) -> DocstoreManager.updateDoc project._id.toString(), doc._id.toString(), docLines, (err, modified, rev) ->
return callback(err) if err? 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? return callback(err) if err?
tpdsUpdateSender.addDoc { tpdsUpdateSender.addDoc {
project_id: project?._id, project_id: project?._id,
@ -194,10 +194,11 @@ module.exports = ProjectEntityHandler =
FileStoreHandler.copyFile originalProject_id, origonalFileRef._id, project._id, fileRef._id, (err)-> FileStoreHandler.copyFile originalProject_id, origonalFileRef._id, project._id, fileRef._id, (err)->
if 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" 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)=> ProjectEntityHandler._putElement project._id, folder_id, fileRef, "file", (err, result)=>
if err? if err?
logger.err err:err, project_id:project._id, folder_id:folder_id, "error putting element as part of copy" 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) -> 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) callback(error, fileRef, folder_id)
@ -463,7 +464,7 @@ module.exports = ProjectEntityHandler =
if !element? if !element?
e = new Error("no element passed to be inserted") 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) return callback(e)
type = sanitizeTypeOfElement type type = sanitizeTypeOfElement type
ProjectGetter.getProject project_or_id, {rootFolder:true}, (err, project)=> ProjectGetter.getProject project_or_id, {rootFolder:true}, (err, project)=>

View file

@ -128,17 +128,17 @@ describe 'ProjectDuplicator', ->
it 'should copy all the folders', (done)-> it 'should copy all the folders', (done)->
@duplicator.duplicate @owner, @project_id, "", (err, newProject)=> @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, @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, @newFolder._id, @level2folder.name).should.equal true
@entityHandler.addFolder.callCount.should.equal 2 @entityHandler.addFolder.callCount.should.equal 2
done() done()
it 'should copy all the docs', (done)-> it 'should copy all the docs', (done)->
@duplicator.duplicate @owner, @project_id, "", (err, newProject)=> @duplicator.duplicate @owner, @project_id, "", (err, newProject)=>
@DocstoreManager.getAllDocs.calledWith(@project_id).should.equal true @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, @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, @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, @newFolder._id, @doc2.name, @doc2_lines).should.equal true
done() done()
it 'should copy all the files', (done)-> it 'should copy all the files', (done)->

View file

@ -59,6 +59,7 @@ describe 'ProjectEntityHandler', ->
@ProjectModel.getProject = (project_id, fields, callback)=> callback(null, @project) @ProjectModel.getProject = (project_id, fields, callback)=> callback(null, @project)
@ProjectGetter = @ProjectGetter =
getProjectWithOnlyFolders : (project_id, callback)=> callback(null, @project) getProjectWithOnlyFolders : (project_id, callback)=> callback(null, @project)
getProjectWithoutDocLines : (project_id, callback)=> callback(null, @project)
getProject:sinon.stub() getProject:sinon.stub()
@projectUpdater = markAsUpdated:sinon.stub() @projectUpdater = markAsUpdated:sinon.stub()
@projectLocator = @projectLocator =
@ -426,9 +427,7 @@ describe 'ProjectEntityHandler', ->
expect(@doc.lines).to.be.undefined expect(@doc.lines).to.be.undefined
it 'should call put element', -> it 'should call put element', ->
@ProjectEntityHandler._putElement @ProjectEntityHandler._putElement.calledWith(@project, folder_id, @doc).should.equal true
.calledWith(project_id, folder_id, @doc)
.should.equal true
it 'should return doc and parent folder', -> it 'should return doc and parent folder', ->
@callback.calledWith(null, @doc, folder_id).should.equal true @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}}) @ProjectModel.update.calledWith({_id : @project_id}, {$unset : {rootDoc_id: true}})
.should.equal true .should.equal true
describe 'copying file', -> describe 'copyFileFromExistingProject', ->
fileName = "something.jpg" fileName = "something.jpg"
filePath = "dumpFolder/somewhere/image.jpeg" filePath = "dumpFolder/somewhere/image.jpeg"
oldProject_id = "123kljadas" oldProject_id = "123kljadas"
oldFileRef = {name:fileName, _id:"oldFileRef"} oldFileRef = {name:fileName, _id:"oldFileRef"}
beforeEach -> 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"}}) @ProjectEntityHandler._putElement = sinon.stub().callsArgWith(4, null, {path:{fileSystem:"somehintg"}})
@ -1041,7 +1040,7 @@ describe 'ProjectEntityHandler', ->
it "should use the correct mongo path", (done)-> it "should use the correct mongo path", (done)->
@ProjectEntityHandler._putElement @project_id, @folder._id, @doc, "docs", (err)=> @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 assert.deepEqual @ProjectModel.update.args[0][1].$push[@path.mongo+".docs"], @doc
done() done()