mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-24 03:23:10 +00:00
remove old rev, not needed any more
This commit is contained in:
parent
a73dc90b00
commit
32829f0e6e
4 changed files with 9 additions and 9 deletions
|
@ -41,7 +41,7 @@ module.exports = DocManager =
|
|||
newDocLines: lines
|
||||
rev: oldRev
|
||||
}, "updating doc lines"
|
||||
MongoManager.upsertIntoDocCollection project_id, doc_id, lines, oldRev, (error)->
|
||||
MongoManager.upsertIntoDocCollection project_id, doc_id, lines, (error)->
|
||||
return callback(callback) if error?
|
||||
callback null, true, oldRev + 1 # rev will have been incremented in mongo by MongoManager.updateDoc
|
||||
|
||||
|
@ -49,7 +49,7 @@ module.exports = DocManager =
|
|||
DocManager.getDoc project_id, doc_id, (error, doc) ->
|
||||
return callback(error) if error?
|
||||
return callback new Errors.NotFoundError("No such project/doc to delete: #{project_id}/#{doc_id}") if !doc?
|
||||
MongoManager.upsertIntoDocCollection project_id, doc_id, doc.lines, doc.rev, (error) ->
|
||||
MongoManager.upsertIntoDocCollection project_id, doc_id, doc.lines, (error) ->
|
||||
return callback(error) if error?
|
||||
MongoManager.markDocAsDeleted doc_id, (error) ->
|
||||
return callback(error) if error?
|
||||
|
|
|
@ -9,7 +9,7 @@ module.exports = MongoManager =
|
|||
getProjectsDocs: (project_id, callback)->
|
||||
db.docs.find project_id: ObjectId(project_id.toString()), {}, callback
|
||||
|
||||
upsertIntoDocCollection: (project_id, doc_id, lines, oldRev, callback)->
|
||||
upsertIntoDocCollection: (project_id, doc_id, lines, callback)->
|
||||
update =
|
||||
$set:{}
|
||||
$inc:{}
|
||||
|
|
|
@ -100,7 +100,7 @@ describe "DocManager", ->
|
|||
@lines = ["mock", "doc", "lines"]
|
||||
@rev = 77
|
||||
@DocManager.getDoc = sinon.stub().callsArgWith(2, null, {lines: @lines, rev:@rev})
|
||||
@MongoManager.upsertIntoDocCollection = sinon.stub().callsArg(4)
|
||||
@MongoManager.upsertIntoDocCollection = sinon.stub().callsArg(3)
|
||||
@MongoManager.markDocAsDeleted = sinon.stub().callsArg(1)
|
||||
@DocManager.deleteDoc @project_id, @doc_id, @callback
|
||||
|
||||
|
@ -111,7 +111,7 @@ describe "DocManager", ->
|
|||
|
||||
it "should update the doc lines", ->
|
||||
@MongoManager.upsertIntoDocCollection
|
||||
.calledWith(@project_id, @doc_id, @lines, @rev)
|
||||
.calledWith(@project_id, @doc_id, @lines)
|
||||
.should.equal true
|
||||
|
||||
it "should mark doc as deleted", ->
|
||||
|
@ -142,7 +142,7 @@ describe "DocManager", ->
|
|||
@newDocLines = ["new", "doc", "lines"]
|
||||
@doc = { _id: @doc_id, lines: @oldDocLines, rev: @rev = 5 }
|
||||
|
||||
@MongoManager.upsertIntoDocCollection = sinon.stub().callsArg(4)
|
||||
@MongoManager.upsertIntoDocCollection = sinon.stub().callsArg(3)
|
||||
@MongoManager.findDoc = sinon.stub()
|
||||
|
||||
describe "when the doc lines have changed", ->
|
||||
|
@ -157,7 +157,7 @@ describe "DocManager", ->
|
|||
|
||||
it "should upsert the document to the doc collection", ->
|
||||
@MongoManager.upsertIntoDocCollection
|
||||
.calledWith(@project_id, @doc_id, @newDocLines, @rev)
|
||||
.calledWith(@project_id, @doc_id, @newDocLines)
|
||||
.should.equal true
|
||||
|
||||
it "should log out the old and new doc lines", ->
|
||||
|
|
|
@ -57,7 +57,7 @@ describe "MongoManager", ->
|
|||
@oldRev = 77
|
||||
|
||||
it "should upsert the document", (done)->
|
||||
@MongoManager.upsertIntoDocCollection @project_id, @doc_id, @lines, @oldRev, (err)=>
|
||||
@MongoManager.upsertIntoDocCollection @project_id, @doc_id, @lines, (err)=>
|
||||
args = @db.docs.update.args[0]
|
||||
assert.deepEqual args[0], {_id: ObjectId(@doc_id)}
|
||||
assert.equal args[1]["$set"]["lines"], @lines
|
||||
|
@ -66,7 +66,7 @@ describe "MongoManager", ->
|
|||
done()
|
||||
|
||||
it "should return the error", (done)->
|
||||
@MongoManager.upsertIntoDocCollection @project_id, @doc_id, @lines, @oldRev, (err)=>
|
||||
@MongoManager.upsertIntoDocCollection @project_id, @doc_id, @lines, (err)=>
|
||||
err.should.equal @stubbedErr
|
||||
done()
|
||||
|
||||
|
|
Loading…
Reference in a new issue