From d60445adfc63f8ae2243089fa37a6401d4e96f8e Mon Sep 17 00:00:00 2001 From: James Allen Date: Tue, 21 Mar 2017 11:32:53 +0000 Subject: [PATCH] Pass undo flag to doc updater when restoring from history --- .../track-changes/app/coffee/DocumentUpdaterManager.coffee | 1 + .../test/acceptance/coffee/RestoringVersions.coffee | 2 +- .../test/acceptance/coffee/helpers/MockDocUpdaterApi.coffee | 4 ++-- .../DocumentUpdaterManager/DocumentUpdaterManagerTests.coffee | 1 + 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/services/track-changes/app/coffee/DocumentUpdaterManager.coffee b/services/track-changes/app/coffee/DocumentUpdaterManager.coffee index 625622206e..a9fc4981c5 100644 --- a/services/track-changes/app/coffee/DocumentUpdaterManager.coffee +++ b/services/track-changes/app/coffee/DocumentUpdaterManager.coffee @@ -30,6 +30,7 @@ module.exports = DocumentUpdaterManager = lines: content.split("\n") source: "restore" user_id: user_id + undoing: true }, (error, res, body)-> if error? return callback(error) diff --git a/services/track-changes/test/acceptance/coffee/RestoringVersions.coffee b/services/track-changes/test/acceptance/coffee/RestoringVersions.coffee index 5dbe094cd8..b09328d2ea 100644 --- a/services/track-changes/test/acceptance/coffee/RestoringVersions.coffee +++ b/services/track-changes/test/acceptance/coffee/RestoringVersions.coffee @@ -65,5 +65,5 @@ describe "Restoring a version", -> it "should set the doc in the doc updater", -> MockDocUpdaterApi.setDoc - .calledWith(@project_id, @doc_id, @restored_lines, @user_id) + .calledWith(@project_id, @doc_id, @restored_lines, @user_id, true) .should.equal true diff --git a/services/track-changes/test/acceptance/coffee/helpers/MockDocUpdaterApi.coffee b/services/track-changes/test/acceptance/coffee/helpers/MockDocUpdaterApi.coffee index 97b4d93772..5ef3506b9c 100644 --- a/services/track-changes/test/acceptance/coffee/helpers/MockDocUpdaterApi.coffee +++ b/services/track-changes/test/acceptance/coffee/helpers/MockDocUpdaterApi.coffee @@ -7,7 +7,7 @@ module.exports = MockDocUpdaterApi = getDoc: (project_id, doc_id, callback = (error) ->) -> callback null, @docs[doc_id] - setDoc: (project_id, doc_id, lines, user_id, callback = (error) ->) -> + setDoc: (project_id, doc_id, lines, user_id, undoing, callback = (error) ->) -> @docs[doc_id] ||= {} @docs[doc_id].lines = lines callback() @@ -23,7 +23,7 @@ module.exports = MockDocUpdaterApi = res.send JSON.stringify doc app.post "/project/:project_id/doc/:doc_id", express.bodyParser(), (req, res, next) => - @setDoc req.params.project_id, req.params.doc_id, req.body.lines, req.body.user_id, (errr, doc) -> + @setDoc req.params.project_id, req.params.doc_id, req.body.lines, req.body.user_id, req.body.undoing, (errr, doc) -> if error? res.send 500 else diff --git a/services/track-changes/test/unit/coffee/DocumentUpdaterManager/DocumentUpdaterManagerTests.coffee b/services/track-changes/test/unit/coffee/DocumentUpdaterManager/DocumentUpdaterManagerTests.coffee index 8c460f4757..2329cf79f5 100644 --- a/services/track-changes/test/unit/coffee/DocumentUpdaterManager/DocumentUpdaterManagerTests.coffee +++ b/services/track-changes/test/unit/coffee/DocumentUpdaterManager/DocumentUpdaterManagerTests.coffee @@ -70,6 +70,7 @@ describe "DocumentUpdaterManager", -> lines: @content.split("\n") source: "restore" user_id: @user_id + undoing: true }).should.equal true it "should call the callback", ->