|
|
@@ -144,6 +144,7 @@ describe 'ProjectEntityHandler', ->
|
|
|
describe 'deleteEntity', ->
|
|
|
entity_id = "4eecaffcbffa66588e000009"
|
|
|
beforeEach ->
|
|
|
+ @ProjectGetter.getProject.callsArgWith(1, null, @project)
|
|
|
@tpdsUpdateSender.deleteEntity = sinon.stub().callsArg(1)
|
|
|
@ProjectEntityHandler._removeElementFromMongoArray = sinon.stub().callsArg(3)
|
|
|
@ProjectEntityHandler._cleanUpEntity = sinon.stub().callsArg(3)
|
|
|
@@ -231,6 +232,7 @@ describe 'ProjectEntityHandler', ->
|
|
|
}
|
|
|
@ProjectEntityHandler._removeElementFromMongoArray = sinon.stub().callsArg(3)
|
|
|
@ProjectEntityHandler._putElement = sinon.stub().callsArgWith(4, null, path: @pathAfterMove)
|
|
|
+ @ProjectGetter.getProject.callsArgWith(1, null, @project)
|
|
|
@tpdsUpdateSender.moveEntity = sinon.stub().callsArg(1)
|
|
|
|
|
|
describe "moving a doc", ->
|
|
|
@@ -567,7 +569,7 @@ describe 'ProjectEntityHandler', ->
|
|
|
@ProjectModel.update = (conditions, update, options, callback)=>
|
|
|
conditions._id.should.equal project_id
|
|
|
differenceInMs = update.$set["#{@filePaths.mongo}.created"].getTime() - d.getTime()
|
|
|
- differenceInMs.should.be.below(10)
|
|
|
+ differenceInMs.should.be.below(20)
|
|
|
done()
|
|
|
|
|
|
@ProjectEntityHandler.replaceFile project_id, @file_id, @fsPath, =>
|
|
|
@@ -808,27 +810,21 @@ describe 'ProjectEntityHandler', ->
|
|
|
@ProjectEntityHandler.getAllDocs = sinon.stub().callsArgWith(1, null, @docs)
|
|
|
@ProjectEntityHandler.getAllFiles = sinon.stub().callsArgWith(1, null, @files)
|
|
|
|
|
|
+ @ProjectGetter.getProject.callsArgWith(1, null, @project)
|
|
|
+
|
|
|
@ProjectEntityHandler.flushProjectToThirdPartyDataStore project_id, () -> done()
|
|
|
|
|
|
it "should flush the project from the doc updater", ->
|
|
|
- @documentUpdaterHandler.flushProjectToMongo
|
|
|
- .calledWith(project_id)
|
|
|
- .should.equal true
|
|
|
+ @documentUpdaterHandler.flushProjectToMongo.calledWith(project_id).should.equal true
|
|
|
|
|
|
it "should look up the project in mongo", ->
|
|
|
- @ProjectModel.findById
|
|
|
- .calledWith(project_id)
|
|
|
- .should.equal true
|
|
|
+ @ProjectGetter.getProject.calledWith(project_id).should.equal true
|
|
|
|
|
|
it "should get all the docs in the project", ->
|
|
|
- @ProjectEntityHandler.getAllDocs
|
|
|
- .calledWith(project_id)
|
|
|
- .should.equal true
|
|
|
+ @ProjectEntityHandler.getAllDocs.calledWith(project_id).should.equal true
|
|
|
|
|
|
it "should get all the files in the project", ->
|
|
|
- @ProjectEntityHandler.getAllFiles
|
|
|
- .calledWith(project_id)
|
|
|
- .should.equal true
|
|
|
+ @ProjectEntityHandler.getAllFiles.calledWith(project_id).should.equal true
|
|
|
|
|
|
it "should flush each doc to the TPDS", ->
|
|
|
for path, doc of @docs
|
|
|
@@ -931,6 +927,7 @@ describe 'ProjectEntityHandler', ->
|
|
|
@projectLocator.findElement = sinon.stub().callsArgWith(1, null, @entity = { _id: @entity_id, name:"old.tex", rev:4 }, @path)
|
|
|
@ProjectModel.update = sinon.stub().callsArgWith(3)
|
|
|
@tpdsUpdateSender.moveEntity = sinon.stub()
|
|
|
+ @ProjectGetter.getProject.callsArgWith(1, null, @project)
|
|
|
|
|
|
it "should update the name in mongo", (done)->
|
|
|
|