fix structure ordering bug

This commit is contained in:
Brian Gough
2018-03-07 17:06:42 +00:00
parent 75a5428cbf
commit 3385d2640a
2 changed files with 14 additions and 7 deletions

View File

@@ -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

View File

@@ -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