|
|
@@ -382,7 +382,9 @@ describe 'ProjectEntityHandler', ->
|
|
|
beforeEach ->
|
|
|
@lines = ["mock", "doc", "lines"]
|
|
|
@rev = 5
|
|
|
- @DocstoreManager.getDoc = sinon.stub().callsArgWith(3, null, @lines, @rev)
|
|
|
+ @version = 42
|
|
|
+ @ranges = {"mock": "ranges"}
|
|
|
+ @DocstoreManager.getDoc = sinon.stub().callsArgWith(3, null, @lines, @rev, @version, @ranges)
|
|
|
@ProjectEntityHandler.getDoc project_id, doc_id, @callback
|
|
|
|
|
|
it "should call the docstore", ->
|
|
|
@@ -391,7 +393,7 @@ describe 'ProjectEntityHandler', ->
|
|
|
.should.equal true
|
|
|
|
|
|
it "should call the callback with the lines, version and rev", ->
|
|
|
- @callback.calledWith(null, @lines, @rev).should.equal true
|
|
|
+ @callback.calledWith(null, @lines, @rev, @version, @ranges).should.equal true
|
|
|
|
|
|
describe 'addDoc', ->
|
|
|
beforeEach ->
|
|
|
@@ -590,6 +592,7 @@ describe 'ProjectEntityHandler', ->
|
|
|
_id: doc_id
|
|
|
}
|
|
|
@version = 42
|
|
|
+ @ranges = {"mock":"ranges"}
|
|
|
@ProjectGetter.getProjectWithoutDocLines = sinon.stub().callsArgWith(1, null, @project)
|
|
|
@projectLocator.findElement = sinon.stub().callsArgWith(1, null, @doc, {fileSystem: @path})
|
|
|
@tpdsUpdateSender.addDoc = sinon.stub().callsArg(1)
|
|
|
@@ -599,7 +602,7 @@ describe 'ProjectEntityHandler', ->
|
|
|
describe "when the doc has been modified", ->
|
|
|
beforeEach ->
|
|
|
@DocstoreManager.updateDoc = sinon.stub().yields(null, true, @rev = 5)
|
|
|
- @ProjectEntityHandler.updateDocLines project_id, doc_id, @lines, @version, @callback
|
|
|
+ @ProjectEntityHandler.updateDocLines project_id, doc_id, @lines, @version, @ranges, @callback
|
|
|
|
|
|
it "should get the project without doc lines", ->
|
|
|
@ProjectGetter.getProjectWithoutDocLines
|
|
|
@@ -617,7 +620,7 @@ describe 'ProjectEntityHandler', ->
|
|
|
|
|
|
it "should update the doc in the docstore", ->
|
|
|
@DocstoreManager.updateDoc
|
|
|
- .calledWith(project_id, doc_id, @lines, @version)
|
|
|
+ .calledWith(project_id, doc_id, @lines, @version, @ranges)
|
|
|
.should.equal true
|
|
|
|
|
|
it "should mark the project as updated", ->
|
|
|
@@ -642,7 +645,7 @@ describe 'ProjectEntityHandler', ->
|
|
|
describe "when the doc has not been modified", ->
|
|
|
beforeEach ->
|
|
|
@DocstoreManager.updateDoc = sinon.stub().yields(null, false, @rev = 5)
|
|
|
- @ProjectEntityHandler.updateDocLines project_id, doc_id, @lines, @version, @callback
|
|
|
+ @ProjectEntityHandler.updateDocLines project_id, doc_id, @lines, @version, @ranges, @callback
|
|
|
|
|
|
it "should not mark the project as updated", ->
|
|
|
@projectUpdater.markAsUpdated.called.should.equal false
|
|
|
@@ -656,7 +659,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, @version, @callback
|
|
|
+ @ProjectEntityHandler.updateDocLines project_id, doc_id, @lines, @ranges, @version, @callback
|
|
|
|
|
|
it "should return a not found error", ->
|
|
|
@callback.calledWith(new Errors.NotFoundError()).should.equal true
|
|
|
@@ -664,7 +667,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, @version, @callback
|
|
|
+ @ProjectEntityHandler.updateDocLines project_id, doc_id, @lines, @ranges, @version, @callback
|
|
|
|
|
|
it "should log out the error", ->
|
|
|
@logger.error
|