Merge pull request #12229 from overleaf/jpa-reject-decrement-doc-version

[docstore] reject doc updates that decrement the doc version

GitOrigin-RevId: 533cc5ece8d5684c85b2f63fa2a093c68f6b5877
This commit is contained in:
Jakob Ackermann
2023-03-22 09:04:55 +00:00
committed by Copybot
parent 90a921cbe6
commit e4efe121da
5 changed files with 72 additions and 0 deletions
@@ -796,6 +796,26 @@ describe('DocManager', function () {
})
})
describe('when the version was decremented', function () {
beforeEach(function () {
this.DocManager._getDoc = sinon.stub().yields(null, this.doc)
this.DocManager.updateDoc(
this.project_id,
this.doc_id,
this.newDocLines,
this.version - 1,
this.originalRanges,
this.callback
)
})
it('should return an error', function () {
this.callback.should.have.been.calledWith(
sinon.match.instanceOf(Errors.DocVersionDecrementedError)
)
})
})
describe('when the doc lines have not changed', function () {
beforeEach(function () {
this.DocManager._getDoc = sinon.stub().callsArgWith(3, null, this.doc)