From 3385d2640a5a8a8e140bf8b4887ab8d5bdcce9fb Mon Sep 17 00:00:00 2001 From: Brian Gough Date: Wed, 7 Mar 2018 17:06:42 +0000 Subject: [PATCH] fix structure ordering bug --- .../app/coffee/ProjectManager.coffee | 4 ++-- .../ProjectManager/updateProjectTests.coffee | 17 ++++++++++++----- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/services/document-updater/app/coffee/ProjectManager.coffee b/services/document-updater/app/coffee/ProjectManager.coffee index 729f1743e8..8ae14cd66e 100644 --- a/services/document-updater/app/coffee/ProjectManager.coffee +++ b/services/document-updater/app/coffee/ProjectManager.coffee @@ -140,9 +140,9 @@ module.exports = ProjectManager = project_ops_length = count cb(error) - async.each docUpdates, handleDocUpdate, (error) -> + async.eachSeries docUpdates, handleDocUpdate, (error) -> return callback(error) if error? - async.each fileUpdates, handleFileUpdate, (error) -> + async.eachSeries fileUpdates, handleFileUpdate, (error) -> return callback(error) if error? if HistoryManager.shouldFlushHistoryOps(project_ops_length, docUpdates.length + fileUpdates.length, HistoryManager.FLUSH_PROJECT_EVERY_N_OPS) HistoryManager.flushProjectChangesAsync project_id diff --git a/services/document-updater/test/unit/coffee/ProjectManager/updateProjectTests.coffee b/services/document-updater/test/unit/coffee/ProjectManager/updateProjectTests.coffee index a5d3e881c6..96d2ccc07b 100644 --- a/services/document-updater/test/unit/coffee/ProjectManager/updateProjectTests.coffee +++ b/services/document-updater/test/unit/coffee/ProjectManager/updateProjectTests.coffee @@ -111,9 +111,12 @@ describe "ProjectManager", -> docLines: "a\nb" @docUpdates = [ @firstDocUpdate, @secondDocUpdate ] @firstFileUpdate = - id: 2 + id: 3 url: 'filestore.example.com/2' - @fileUpdates = [ @firstFileUpdate ] + @secondFileUpdate = + id: 4 + url: 'filestore.example.com/3' + @fileUpdates = [ @firstFileUpdate, @secondFileUpdate ] @ProjectHistoryRedisManager.queueAddEntity = sinon.stub().yields() describe "successfully", -> @@ -123,18 +126,22 @@ describe "ProjectManager", -> it "should add the docs in the updates", -> firstDocUpdateWithVersion = _.extend({}, @firstDocUpdate, {version: "#{@version}.0"}) secondDocUpdateWithVersion = _.extend({}, @secondDocUpdate, {version: "#{@version}.1"}) - @ProjectHistoryRedisManager.queueAddEntity + @ProjectHistoryRedisManager.queueAddEntity.getCall(0) .calledWith(@project_id, 'doc', @firstDocUpdate.id, @user_id, firstDocUpdateWithVersion) .should.equal true - @ProjectHistoryRedisManager.queueAddEntity + @ProjectHistoryRedisManager.queueAddEntity.getCall(1) .calledWith(@project_id, 'doc', @secondDocUpdate.id, @user_id, secondDocUpdateWithVersion) .should.equal true it "should add the files in the updates", -> firstFileUpdateWithVersion = _.extend({}, @firstFileUpdate, {version: "#{@version}.2"}) - @ProjectHistoryRedisManager.queueAddEntity + secondFileUpdateWithVersion = _.extend({}, @secondFileUpdate, {version: "#{@version}.3"}) + @ProjectHistoryRedisManager.queueAddEntity.getCall(2) .calledWith(@project_id, 'file', @firstFileUpdate.id, @user_id, firstFileUpdateWithVersion) .should.equal true + @ProjectHistoryRedisManager.queueAddEntity.getCall(3) + .calledWith(@project_id, 'file', @secondFileUpdate.id, @user_id, secondFileUpdateWithVersion) + .should.equal true it "should not flush the history", -> @HistoryManager.flushProjectChangesAsync