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

Update TrackChangesManagerTests -> HistoryManagerTests

James Allen 10 лет назад
Родитель
Сommit
b6c93c718d

+ 19 - 19
services/document-updater/test/unit/coffee/TrackChangesManager/TrackChangesManagerTests.coffee → services/document-updater/test/unit/coffee/HistoryManager/HistoryManagerTests.coffee

@@ -1,11 +1,11 @@
 SandboxedModule = require('sandboxed-module')
 SandboxedModule = require('sandboxed-module')
 sinon = require('sinon')
 sinon = require('sinon')
 require('chai').should()
 require('chai').should()
-modulePath = require('path').join __dirname, '../../../../app/js/TrackChangesManager'
+modulePath = require('path').join __dirname, '../../../../app/js/HistoryManager'
 
 
-describe "TrackChangesManager", ->
+describe "HistoryManager", ->
 	beforeEach ->
 	beforeEach ->
-		@TrackChangesManager = SandboxedModule.require modulePath, requires:
+		@HistoryManager = SandboxedModule.require modulePath, requires:
 			"request": @request = {}
 			"request": @request = {}
 			"settings-sharelatex": @Settings = {}
 			"settings-sharelatex": @Settings = {}
 			"logger-sharelatex": @logger = { log: sinon.stub(), error: sinon.stub() }
 			"logger-sharelatex": @logger = { log: sinon.stub(), error: sinon.stub() }
@@ -22,7 +22,7 @@ describe "TrackChangesManager", ->
 		describe "successfully", ->
 		describe "successfully", ->
 			beforeEach ->
 			beforeEach ->
 				@request.post = sinon.stub().callsArgWith(1, null, statusCode: 204)
 				@request.post = sinon.stub().callsArgWith(1, null, statusCode: 204)
-				@TrackChangesManager.flushDocChanges @project_id, @doc_id, @callback
+				@HistoryManager.flushDocChanges @project_id, @doc_id, @callback
 
 
 			it "should send a request to the track changes api", ->
 			it "should send a request to the track changes api", ->
 				@request.post
 				@request.post
@@ -35,7 +35,7 @@ describe "TrackChangesManager", ->
 		describe "when the track changes api returns an error", ->
 		describe "when the track changes api returns an error", ->
 			beforeEach ->
 			beforeEach ->
 				@request.post = sinon.stub().callsArgWith(1, null, statusCode: 500)
 				@request.post = sinon.stub().callsArgWith(1, null, statusCode: 500)
-				@TrackChangesManager.flushDocChanges @project_id, @doc_id, @callback
+				@HistoryManager.flushDocChanges @project_id, @doc_id, @callback
 
 
 			it "should return the callback with an error", ->
 			it "should return the callback with an error", ->
 				@callback.calledWith(new Error("track changes api return non-success code: 500")).should.equal true
 				@callback.calledWith(new Error("track changes api return non-success code: 500")).should.equal true
@@ -43,12 +43,12 @@ describe "TrackChangesManager", ->
 	describe "pushUncompressedHistoryOps", ->
 	describe "pushUncompressedHistoryOps", ->
 		beforeEach ->
 		beforeEach ->
 			@ops = ["mock-ops"]
 			@ops = ["mock-ops"]
-			@TrackChangesManager.flushDocChanges = sinon.stub().callsArg(2)
+			@HistoryManager.flushDocChanges = sinon.stub().callsArg(2)
 
 
 		describe "pushing the op", ->
 		describe "pushing the op", ->
 			beforeEach ->
 			beforeEach ->
 				@WebRedisManager.pushUncompressedHistoryOps = sinon.stub().callsArgWith(3, null, 1)
 				@WebRedisManager.pushUncompressedHistoryOps = sinon.stub().callsArgWith(3, null, 1)
-				@TrackChangesManager.pushUncompressedHistoryOps @project_id, @doc_id, @ops, @callback
+				@HistoryManager.pushUncompressedHistoryOps @project_id, @doc_id, @ops, @callback
 
 
 			it "should push the ops into redis", ->
 			it "should push the ops into redis", ->
 				@WebRedisManager.pushUncompressedHistoryOps
 				@WebRedisManager.pushUncompressedHistoryOps
@@ -59,16 +59,16 @@ describe "TrackChangesManager", ->
 				@callback.called.should.equal true
 				@callback.called.should.equal true
 
 
 			it "should not try to flush the op", ->
 			it "should not try to flush the op", ->
-				@TrackChangesManager.flushDocChanges.called.should.equal false
+				@HistoryManager.flushDocChanges.called.should.equal false
 
 
 		describe "when we hit a multiple of FLUSH_EVERY_N_OPS ops", ->
 		describe "when we hit a multiple of FLUSH_EVERY_N_OPS ops", ->
 			beforeEach ->
 			beforeEach ->
 				@WebRedisManager.pushUncompressedHistoryOps =
 				@WebRedisManager.pushUncompressedHistoryOps =
-					sinon.stub().callsArgWith(3, null, 2 * @TrackChangesManager.FLUSH_EVERY_N_OPS)
-				@TrackChangesManager.pushUncompressedHistoryOps @project_id, @doc_id, @ops, @callback
+					sinon.stub().callsArgWith(3, null, 2 * @HistoryManager.FLUSH_EVERY_N_OPS)
+				@HistoryManager.pushUncompressedHistoryOps @project_id, @doc_id, @ops, @callback
 
 
 			it "should tell the track changes api to flush", ->
 			it "should tell the track changes api to flush", ->
-				@TrackChangesManager.flushDocChanges
+				@HistoryManager.flushDocChanges
 					.calledWith(@project_id, @doc_id)
 					.calledWith(@project_id, @doc_id)
 					.should.equal true
 					.should.equal true
 
 
@@ -76,20 +76,20 @@ describe "TrackChangesManager", ->
 			beforeEach ->
 			beforeEach ->
 				@ops = ["op1", "op2", "op3"]
 				@ops = ["op1", "op2", "op3"]
 				@WebRedisManager.pushUncompressedHistoryOps =
 				@WebRedisManager.pushUncompressedHistoryOps =
-					sinon.stub().callsArgWith(3, null, 2 * @TrackChangesManager.FLUSH_EVERY_N_OPS + 1)
-				@TrackChangesManager.pushUncompressedHistoryOps @project_id, @doc_id, @ops, @callback
+					sinon.stub().callsArgWith(3, null, 2 * @HistoryManager.FLUSH_EVERY_N_OPS + 1)
+				@HistoryManager.pushUncompressedHistoryOps @project_id, @doc_id, @ops, @callback
 
 
 			it "should tell the track changes api to flush", ->
 			it "should tell the track changes api to flush", ->
-				@TrackChangesManager.flushDocChanges
+				@HistoryManager.flushDocChanges
 					.calledWith(@project_id, @doc_id)
 					.calledWith(@project_id, @doc_id)
 					.should.equal true
 					.should.equal true
 
 
-		describe "when TrackChangesManager errors", ->
+		describe "when HistoryManager errors", ->
 			beforeEach ->
 			beforeEach ->
 				@WebRedisManager.pushUncompressedHistoryOps =
 				@WebRedisManager.pushUncompressedHistoryOps =
-					sinon.stub().callsArgWith(3, null, 2 * @TrackChangesManager.FLUSH_EVERY_N_OPS)
-				@TrackChangesManager.flushDocChanges = sinon.stub().callsArgWith(2, @error = new Error("oops"))
-				@TrackChangesManager.pushUncompressedHistoryOps @project_id, @doc_id, @ops, @callback
+					sinon.stub().callsArgWith(3, null, 2 * @HistoryManager.FLUSH_EVERY_N_OPS)
+				@HistoryManager.flushDocChanges = sinon.stub().callsArgWith(2, @error = new Error("oops"))
+				@HistoryManager.pushUncompressedHistoryOps @project_id, @doc_id, @ops, @callback
 
 
 			it "should log out the error", ->
 			it "should log out the error", ->
 				@logger.error
 				@logger.error
@@ -104,7 +104,7 @@ describe "TrackChangesManager", ->
 		describe "with no ops", ->
 		describe "with no ops", ->
 			beforeEach ->
 			beforeEach ->
 				@WebRedisManager.pushUncompressedHistoryOps = sinon.stub().callsArgWith(3, null, 1)
 				@WebRedisManager.pushUncompressedHistoryOps = sinon.stub().callsArgWith(3, null, 1)
-				@TrackChangesManager.pushUncompressedHistoryOps @project_id, @doc_id, [], @callback
+				@HistoryManager.pushUncompressedHistoryOps @project_id, @doc_id, [], @callback
 			
 			
 			it "should not call WebRedisManager.pushUncompressedHistoryOps", ->
 			it "should not call WebRedisManager.pushUncompressedHistoryOps", ->
 				@WebRedisManager.pushUncompressedHistoryOps.called.should.equal false
 				@WebRedisManager.pushUncompressedHistoryOps.called.should.equal false