Просмотр исходного кода

Push ops into uncompressedHistoryOps list

James Allen 12 лет назад
Родитель
Сommit
b13f70eadb

+ 1 - 1
services/document-updater/Gruntfile.coffee

@@ -103,7 +103,7 @@ module.exports = (grunt) ->
 
 	grunt.registerTask 'install', "Compile everything when installing as an npm module", ['compile']
 
-	grunt.registerTask 'test:unit', 'Run the unit tests (use --grep=<regex> for individual tests)', ['compile:unit_tests', 'mochaTest:unit']
+	grunt.registerTask 'test:unit', 'Run the unit tests (use --grep=<regex> for individual tests)', ['compile:server', 'compile:unit_tests', 'mochaTest:unit']
 	grunt.registerTask 'test:acceptance', 'Run the acceptance tests (use --grep=<regex> for individual tests)', ['compile:acceptance_tests', 'mochaTest:acceptance']
 
 	grunt.registerTask 'run', "Compile and run the document-updater-sharelatex server", ['compile', 'bunyan', 'execute']

+ 3 - 2
services/document-updater/app/coffee/DocOpsManager.coffee

@@ -44,8 +44,9 @@ module.exports = DocOpsManager =
 				callback null, ops
 
 	pushDocOp: (project_id, doc_id, op, callback = (error) ->) ->
-		console.log "PUSHING OP", op
-		RedisManager.pushDocOp doc_id, op, callback
+		RedisManager.pushDocOp doc_id, op, (error) ->
+			return callback(error) if error?
+			RedisManager.pushUncompressedHistoryOp doc_id, op, callback
 
 	_ensureOpsAreLoaded: (project_id, doc_id, backToVersion, callback = (error) ->) ->
 		RedisManager.getDocVersion doc_id, (error, redisVersion) ->

+ 1 - 1
services/document-updater/app/coffee/ShareJsDB.coffee

@@ -23,7 +23,7 @@ module.exports = ShareJsDB =
 	
 	writeOp: (doc_key, opData, callback) ->
 		[project_id, doc_id] = Keys.splitProjectIdAndDocId(doc_key)
-		DocOpsManager.pushDocOp project_id, doc_id, {op:opData.op, meta:opData.meta}, (error, version) ->
+		DocOpsManager.pushDocOp project_id, doc_id, opData, (error, version) ->
 			return callback error if error?
 
 			if version == opData.v + 1

+ 20 - 0
services/document-updater/test/unit/coffee/DocOpsManager/DocOpsManagerTests.coffee

@@ -306,4 +306,24 @@ describe "DocOpsManager", ->
 		it "should return the ops", ->
 			@callback.calledWith(null, @doc.docOps).should.equal true
 
+	describe "pushDocOp", ->
+		beforeEach ->
+			@op = "mock-op"
+			@RedisManager.pushDocOp = sinon.stub().callsArg(2)
+			@RedisManager.pushUncompressedHistoryOp = sinon.stub().callsArg(2)
+			@DocOpsManager.pushDocOp @project_id, @doc_id, @op, @callback
+
+		it "should push the op in to the docOps list", ->
+			@RedisManager.pushDocOp
+				.calledWith(@doc_id, @op)
+				.should.equal true
+
+		it "should push the op into the pushUncompressedHistoryOp", ->
+			@RedisManager.pushUncompressedHistoryOp
+				.calledWith(@doc_id, @op)
+				.should.equal true
+
+		it "should call the callback", ->
+			@callback.called.should.equal true
+