From 32829f0e6ea7b4a7550bb2fec89683b2b7043db0 Mon Sep 17 00:00:00 2001 From: Henry Oswald Date: Fri, 27 Feb 2015 14:06:06 +0000 Subject: [PATCH] remove old rev, not needed any more --- services/docstore/app/coffee/DocManager.coffee | 4 ++-- services/docstore/app/coffee/MongoManager.coffee | 2 +- services/docstore/test/unit/coffee/DocManagerTests.coffee | 8 ++++---- .../docstore/test/unit/coffee/MongoManagerTests.coffee | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/services/docstore/app/coffee/DocManager.coffee b/services/docstore/app/coffee/DocManager.coffee index fbf201bcd5..4cef291854 100644 --- a/services/docstore/app/coffee/DocManager.coffee +++ b/services/docstore/app/coffee/DocManager.coffee @@ -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? diff --git a/services/docstore/app/coffee/MongoManager.coffee b/services/docstore/app/coffee/MongoManager.coffee index 8db8d57dc3..352483fbfc 100644 --- a/services/docstore/app/coffee/MongoManager.coffee +++ b/services/docstore/app/coffee/MongoManager.coffee @@ -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:{} diff --git a/services/docstore/test/unit/coffee/DocManagerTests.coffee b/services/docstore/test/unit/coffee/DocManagerTests.coffee index 81bd9a3a6d..b09ed900c8 100644 --- a/services/docstore/test/unit/coffee/DocManagerTests.coffee +++ b/services/docstore/test/unit/coffee/DocManagerTests.coffee @@ -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", -> diff --git a/services/docstore/test/unit/coffee/MongoManagerTests.coffee b/services/docstore/test/unit/coffee/MongoManagerTests.coffee index 97f09035e8..b0e7c07e97 100644 --- a/services/docstore/test/unit/coffee/MongoManagerTests.coffee +++ b/services/docstore/test/unit/coffee/MongoManagerTests.coffee @@ -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()