Remove all traces of soa-req-id

This commit is contained in:
James Allen
2014-10-15 14:11:02 +01:00
parent fd8991f62e
commit 941f550d6c
18 changed files with 186 additions and 237 deletions
@@ -30,7 +30,7 @@ describe 'ProjectCreationHandler', ->
constructor:(options)->
{@name} = options
@ProjectEntityHandler =
addDoc: sinon.stub().callsArgWith(5, null, {_id: docId})
addDoc: sinon.stub().callsArgWith(4, null, {_id: docId})
addFile: sinon.stub().callsArg(4)
setRootDoc: sinon.stub().callsArg(2)
@@ -20,9 +20,9 @@ describe 'ProjectEntityHandler', ->
uploadFileFromDisk:(project_id, fileRef, localImagePath, callback)->callback()
copyFile: sinon.stub().callsArgWith(4, null)
@tpdsUpdateSender =
addDoc:sinon.stub().callsArg(2)
addFile:sinon.stub().callsArg(2)
addFolder:sinon.stub().callsArg(2)
addDoc:sinon.stub().callsArg(1)
addFile:sinon.stub().callsArg(1)
addFolder:sinon.stub().callsArg(1)
@rootFolder =
_id:rootFolderId,
folders:[
@@ -84,7 +84,7 @@ describe 'ProjectEntityHandler', ->
cb "level1 is not the last foler "
else
cb null, @parentFolder
@ProjectEntityHandler.addFolder = (project_id, parentFolder_id, folderName, sl_req_id, callback)=>
@ProjectEntityHandler.addFolder = (project_id, parentFolder_id, folderName, callback)=>
callback null, {name:folderName}, @parentFolder_id
it 'should return the root folder if the path is just a slash', (done)->
@@ -134,10 +134,10 @@ describe 'ProjectEntityHandler', ->
lastFolder.parentFolder_id.should.equal @parentFolder_id
done()
describe 'deleting an element', ->
describe 'deleteEntity', ->
entity_id = "4eecaffcbffa66588e000009"
beforeEach ->
@tpdsUpdateSender.deleteEntity = sinon.stub().callsArg(2)
@tpdsUpdateSender.deleteEntity = sinon.stub().callsArg(1)
@ProjectEntityHandler._removeElementFromMongoArray = sinon.stub().callsArg(3)
@ProjectEntityHandler._cleanUpEntity = sinon.stub().callsArg(3)
@path = mongo: "mongo.path", fileSystem: "/file/system/path"
@@ -186,7 +186,7 @@ describe 'ProjectEntityHandler', ->
describe "a doc", ->
beforeEach (done) ->
@ProjectEntityHandler._cleanUpDoc = sinon.stub().callsArg(3)
@ProjectEntityHandler._cleanUpDoc = sinon.stub().callsArg(2)
@ProjectEntityHandler._cleanUpEntity @project, @entity = {_id: @entity_id}, 'doc', done
it "should clean up the doc", ->
@@ -205,8 +205,8 @@ describe 'ProjectEntityHandler', ->
fileRefs: [ @file2 = { _id: "file-id-2" } ]
docs: [ @doc2 = { _id: "doc-id-2" } ]
@ProjectEntityHandler._cleanUpDoc = sinon.stub().callsArg(3)
@ProjectEntityHandler._cleanUpFile = sinon.stub().callsArg(3)
@ProjectEntityHandler._cleanUpDoc = sinon.stub().callsArg(2)
@ProjectEntityHandler._cleanUpFile = sinon.stub().callsArg(2)
@ProjectEntityHandler._cleanUpEntity @project, @folder, "folder", done
it "should clean up all sub files", ->
@@ -406,7 +406,7 @@ describe 'ProjectEntityHandler', ->
@ProjectModel.putElement = sinon.stub().callsArgWith(4, null, {path:{fileSystem:@path}})
@callback = sinon.stub()
@tpdsUpdateSender.addDoc = sinon.stub().callsArg(2)
@tpdsUpdateSender.addDoc = sinon.stub().callsArg(1)
@DocstoreManager.updateDoc = sinon.stub().callsArgWith(3, null, true, 0)
@ProjectEntityHandler.addDoc project_id, folder_id, @name, @lines, @callback
@@ -465,7 +465,7 @@ describe 'ProjectEntityHandler', ->
it "should call the callback with the new folder and doc", ->
@callback.calledWith(null, @doc, @folder_id).should.equal true
describe 'adding file', ->
describe 'addFile', ->
fileName = "something.jpg"
beforeEach ->
@filePath = "somewhere"
@@ -786,8 +786,8 @@ describe 'ProjectEntityHandler', ->
}
@ProjectModel.findById = sinon.stub().callsArgWith(1, null, @project)
@documentUpdaterHandler.flushProjectToMongo = sinon.stub().callsArg(2)
@tpdsUpdateSender.addDoc = sinon.stub().callsArg(2)
@tpdsUpdateSender.addFile = sinon.stub().callsArg(2)
@tpdsUpdateSender.addDoc = sinon.stub().callsArg(1)
@tpdsUpdateSender.addFile = sinon.stub().callsArg(1)
@docs = {
"/doc/one": @doc1 = { _id: "mock-doc-1", lines: ["one"], rev: 5 }
"/doc/two": @doc2 = { _id: "mock-doc-2", lines: ["two"], rev: 6 }
@@ -8,6 +8,7 @@ describe 'ProjectRootDocManager', ->
beforeEach ->
@project_id = "project-123"
@sl_req_id = "sl-req-id-123"
@callback = sinon.stub()
@ProjectRootDocManager = SandboxedModule.require modulePath, requires:
"./ProjectEntityHandler" : @ProjectEntityHandler = {}
@@ -21,9 +22,9 @@ describe 'ProjectRootDocManager', ->
"/main.tex":
_id: "doc-id-2"
lines: ["\\documentclass{article}", "\\input{chapter1}"]
@ProjectEntityHandler.getAllDocs = sinon.stub().callsArgWith(2, null, @docs)
@ProjectEntityHandler.setRootDoc = sinon.stub().callsArgWith(3)
@ProjectRootDocManager.setRootDocAutomatically @project_id, @sl_req_id, @callback
@ProjectEntityHandler.getAllDocs = sinon.stub().callsArgWith(1, null, @docs)
@ProjectEntityHandler.setRootDoc = sinon.stub().callsArgWith(2)
@ProjectRootDocManager.setRootDocAutomatically @project_id, @callback
it "should check the docs of the project", ->
@ProjectEntityHandler.getAllDocs.calledWith(@project_id)
@@ -36,12 +37,6 @@ describe 'ProjectRootDocManager', ->
it "should call the callback", ->
@callback.called.should.equal true
it "should pass on the sl_req_id", ->
@ProjectEntityHandler.getAllDocs.calledWith(sinon.match.any, @sl_req_id)
.should.equal true
@ProjectEntityHandler.setRootDoc.calledWith(sinon.match.any, sinon.match.any, @sl_req_id)
.should.equal true
describe "when the root doc is an Rtex file", ->
beforeEach ->
@docs =
@@ -51,9 +46,9 @@ describe 'ProjectRootDocManager', ->
"/main.Rtex":
_id: "doc-id-2"
lines: ["\\documentclass{article}", "\\input{chapter1}"]
@ProjectEntityHandler.getAllDocs = sinon.stub().callsArgWith(2, null, @docs)
@ProjectEntityHandler.setRootDoc = sinon.stub().callsArgWith(3)
@ProjectRootDocManager.setRootDocAutomatically @project_id, @sl_req_id, @callback
@ProjectEntityHandler.getAllDocs = sinon.stub().callsArgWith(1, null, @docs)
@ProjectEntityHandler.setRootDoc = sinon.stub().callsArgWith(2)
@ProjectRootDocManager.setRootDocAutomatically @project_id, @callback
it "should set the root doc to the doc containing a documentclass", ->
@ProjectEntityHandler.setRootDoc.calledWith(@project_id, "doc-id-2")
@@ -68,8 +63,8 @@ describe 'ProjectRootDocManager', ->
"/style.bst":
_id: "doc-id-2"
lines: ["%Example: \\documentclass{article}"]
@ProjectEntityHandler.getAllDocs = sinon.stub().callsArgWith(2, null, @docs)
@ProjectEntityHandler.setRootDoc = sinon.stub().callsArgWith(3)
@ProjectEntityHandler.getAllDocs = sinon.stub().callsArgWith(1, null, @docs)
@ProjectEntityHandler.setRootDoc = sinon.stub().callsArgWith(2)
@ProjectRootDocManager.setRootDocAutomatically @project_id, @callback
it "should not set the root doc to the doc containing a documentclass", ->