|
|
@@ -402,7 +402,7 @@ describe 'ProjectEntityHandler', ->
|
|
|
@ProjectEntityHandler._putElement = sinon.stub().callsArgWith(4, null, {path:{fileSystem:@path}})
|
|
|
@callback = sinon.stub()
|
|
|
@tpdsUpdateSender.addDoc = sinon.stub().callsArg(1)
|
|
|
- @DocstoreManager.updateDoc = sinon.stub().callsArgWith(3, null, true, 0)
|
|
|
+ @DocstoreManager.updateDoc = sinon.stub().yields(null, true, 0)
|
|
|
|
|
|
@ProjectEntityHandler.addDoc project_id, folder_id, @name, @lines, @callback
|
|
|
|
|
|
@@ -589,6 +589,7 @@ describe 'ProjectEntityHandler', ->
|
|
|
@doc = {
|
|
|
_id: doc_id
|
|
|
}
|
|
|
+ @version = 42
|
|
|
@ProjectGetter.getProjectWithoutDocLines = sinon.stub().callsArgWith(1, null, @project)
|
|
|
@projectLocator.findElement = sinon.stub().callsArgWith(1, null, @doc, {fileSystem: @path})
|
|
|
@tpdsUpdateSender.addDoc = sinon.stub().callsArg(1)
|
|
|
@@ -597,8 +598,8 @@ describe 'ProjectEntityHandler', ->
|
|
|
|
|
|
describe "when the doc has been modified", ->
|
|
|
beforeEach ->
|
|
|
- @DocstoreManager.updateDoc = sinon.stub().callsArgWith(3, null, true, @rev = 5)
|
|
|
- @ProjectEntityHandler.updateDocLines project_id, doc_id, @lines, @callback
|
|
|
+ @DocstoreManager.updateDoc = sinon.stub().yields(null, true, @rev = 5)
|
|
|
+ @ProjectEntityHandler.updateDocLines project_id, doc_id, @lines, @version, @callback
|
|
|
|
|
|
it "should get the project without doc lines", ->
|
|
|
@ProjectGetter.getProjectWithoutDocLines
|
|
|
@@ -616,7 +617,7 @@ describe 'ProjectEntityHandler', ->
|
|
|
|
|
|
it "should update the doc in the docstore", ->
|
|
|
@DocstoreManager.updateDoc
|
|
|
- .calledWith(project_id, doc_id, @lines)
|
|
|
+ .calledWith(project_id, doc_id, @lines, @version)
|
|
|
.should.equal true
|
|
|
|
|
|
it "should mark the project as updated", ->
|
|
|
@@ -640,8 +641,8 @@ describe 'ProjectEntityHandler', ->
|
|
|
|
|
|
describe "when the doc has not been modified", ->
|
|
|
beforeEach ->
|
|
|
- @DocstoreManager.updateDoc = sinon.stub().callsArgWith(3, null, false, @rev = 5)
|
|
|
- @ProjectEntityHandler.updateDocLines project_id, doc_id, @lines, @callback
|
|
|
+ @DocstoreManager.updateDoc = sinon.stub().yields(null, false, @rev = 5)
|
|
|
+ @ProjectEntityHandler.updateDocLines project_id, doc_id, @lines, @version, @callback
|
|
|
|
|
|
it "should not mark the project as updated", ->
|
|
|
@projectUpdater.markAsUpdated.called.should.equal false
|
|
|
@@ -655,7 +656,7 @@ describe 'ProjectEntityHandler', ->
|
|
|
describe "when the project is not found", ->
|
|
|
beforeEach ->
|
|
|
@ProjectGetter.getProjectWithoutDocLines = sinon.stub().callsArgWith(1, null, null)
|
|
|
- @ProjectEntityHandler.updateDocLines project_id, doc_id, @lines, @callback
|
|
|
+ @ProjectEntityHandler.updateDocLines project_id, doc_id, @lines, @version, @callback
|
|
|
|
|
|
it "should return a not found error", ->
|
|
|
@callback.calledWith(new Errors.NotFoundError()).should.equal true
|
|
|
@@ -663,7 +664,7 @@ describe 'ProjectEntityHandler', ->
|
|
|
describe "when the doc is not found", ->
|
|
|
beforeEach ->
|
|
|
@projectLocator.findElement = sinon.stub().callsArgWith(1, null, null, null)
|
|
|
- @ProjectEntityHandler.updateDocLines project_id, doc_id, @lines, @callback
|
|
|
+ @ProjectEntityHandler.updateDocLines project_id, doc_id, @lines, @version, @callback
|
|
|
|
|
|
it "should log out the error", ->
|
|
|
@logger.error
|