Răsfoiți Sursa

fix structure ordering bug

Brian Gough 8 ani în urmă
părinte
comite
3385d2640a

+ 2 - 2
services/document-updater/app/coffee/ProjectManager.coffee

@@ -140,9 +140,9 @@ module.exports = ProjectManager =
 					project_ops_length = count
 					project_ops_length = count
 					cb(error)
 					cb(error)
 
 
-		async.each docUpdates, handleDocUpdate, (error) ->
+		async.eachSeries docUpdates, handleDocUpdate, (error) ->
 			return callback(error) if error?
 			return callback(error) if error?
-			async.each fileUpdates, handleFileUpdate, (error) ->
+			async.eachSeries fileUpdates, handleFileUpdate, (error) ->
 				return callback(error) if error?
 				return callback(error) if error?
 				if HistoryManager.shouldFlushHistoryOps(project_ops_length, docUpdates.length + fileUpdates.length, HistoryManager.FLUSH_PROJECT_EVERY_N_OPS)
 				if HistoryManager.shouldFlushHistoryOps(project_ops_length, docUpdates.length + fileUpdates.length, HistoryManager.FLUSH_PROJECT_EVERY_N_OPS)
 					HistoryManager.flushProjectChangesAsync project_id
 					HistoryManager.flushProjectChangesAsync project_id

+ 12 - 5
services/document-updater/test/unit/coffee/ProjectManager/updateProjectTests.coffee

@@ -111,9 +111,12 @@ describe "ProjectManager", ->
 					docLines: "a\nb"
 					docLines: "a\nb"
 				@docUpdates = [ @firstDocUpdate, @secondDocUpdate ]
 				@docUpdates = [ @firstDocUpdate, @secondDocUpdate ]
 				@firstFileUpdate =
 				@firstFileUpdate =
-					id: 2
+					id: 3
 					url: 'filestore.example.com/2'
 					url: 'filestore.example.com/2'
-				@fileUpdates = [ @firstFileUpdate ]
+				@secondFileUpdate =
+					id: 4
+					url: 'filestore.example.com/3'
+				@fileUpdates = [ @firstFileUpdate, @secondFileUpdate ]
 				@ProjectHistoryRedisManager.queueAddEntity = sinon.stub().yields()
 				@ProjectHistoryRedisManager.queueAddEntity = sinon.stub().yields()
 
 
 			describe "successfully", ->
 			describe "successfully", ->
@@ -123,18 +126,22 @@ describe "ProjectManager", ->
 				it "should add the docs in the updates", ->
 				it "should add the docs in the updates", ->
 					firstDocUpdateWithVersion = _.extend({}, @firstDocUpdate, {version: "#{@version}.0"})
 					firstDocUpdateWithVersion = _.extend({}, @firstDocUpdate, {version: "#{@version}.0"})
 					secondDocUpdateWithVersion = _.extend({}, @secondDocUpdate, {version: "#{@version}.1"})
 					secondDocUpdateWithVersion = _.extend({}, @secondDocUpdate, {version: "#{@version}.1"})
-					@ProjectHistoryRedisManager.queueAddEntity
+					@ProjectHistoryRedisManager.queueAddEntity.getCall(0)
 						.calledWith(@project_id, 'doc', @firstDocUpdate.id, @user_id, firstDocUpdateWithVersion)
 						.calledWith(@project_id, 'doc', @firstDocUpdate.id, @user_id, firstDocUpdateWithVersion)
 						.should.equal true
 						.should.equal true
-					@ProjectHistoryRedisManager.queueAddEntity
+					@ProjectHistoryRedisManager.queueAddEntity.getCall(1)
 						.calledWith(@project_id, 'doc', @secondDocUpdate.id, @user_id, secondDocUpdateWithVersion)
 						.calledWith(@project_id, 'doc', @secondDocUpdate.id, @user_id, secondDocUpdateWithVersion)
 						.should.equal true
 						.should.equal true
 
 
 				it "should add the files in the updates", ->
 				it "should add the files in the updates", ->
 					firstFileUpdateWithVersion = _.extend({}, @firstFileUpdate, {version: "#{@version}.2"})
 					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)
 						.calledWith(@project_id, 'file', @firstFileUpdate.id, @user_id, firstFileUpdateWithVersion)
 						.should.equal true
 						.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", ->
 				it "should not flush the history", ->
 					@HistoryManager.flushProjectChangesAsync
 					@HistoryManager.flushProjectChangesAsync