mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-29 13:53:40 -05:00
rename HistoryManager pushUncompressedHistoryOps
This commit is contained in:
parent
7ce6285e3d
commit
36407ac726
4 changed files with 10 additions and 10 deletions
|
@ -22,7 +22,7 @@ module.exports = HistoryManager =
|
|||
return callback(error)
|
||||
|
||||
FLUSH_EVERY_N_OPS: 100
|
||||
pushUncompressedHistoryOps: (project_id, doc_id, ops = [], length, callback = (error) ->) ->
|
||||
recordAndFlushHistoryOps: (project_id, doc_id, ops = [], length, callback = (error) ->) ->
|
||||
if ops.length == 0
|
||||
return callback()
|
||||
HistoryRedisManager.recordDocHasHistoryOps project_id, doc_id, ops, (error) ->
|
||||
|
|
|
@ -63,7 +63,7 @@ module.exports = UpdateManager =
|
|||
return callback(error) if error?
|
||||
RedisManager.updateDocument doc_id, updatedDocLines, version, appliedOps, new_ranges, (error, historyOpsLength) ->
|
||||
return callback(error) if error?
|
||||
HistoryManager.pushUncompressedHistoryOps project_id, doc_id, appliedOps, historyOpsLength, callback
|
||||
HistoryManager.recordAndFlushHistoryOps project_id, doc_id, appliedOps, historyOpsLength, callback
|
||||
|
||||
lockUpdatesAndDo: (method, project_id, doc_id, args..., callback) ->
|
||||
LockManager.getLock doc_id, (error, lockValue) ->
|
||||
|
|
|
@ -40,7 +40,7 @@ describe "HistoryManager", ->
|
|||
it "should return the callback with an error", ->
|
||||
@callback.calledWith(new Error("track changes api return non-success code: 500")).should.equal true
|
||||
|
||||
describe "pushUncompressedHistoryOps", ->
|
||||
describe "recordAndFlushHistoryOps", ->
|
||||
beforeEach ->
|
||||
@ops = ["mock-ops"]
|
||||
@HistoryManager.flushDocChanges = sinon.stub().callsArg(2)
|
||||
|
@ -48,7 +48,7 @@ describe "HistoryManager", ->
|
|||
describe "pushing the op", ->
|
||||
beforeEach ->
|
||||
@HistoryRedisManager.recordDocHasHistoryOps = sinon.stub().callsArgWith(3, null)
|
||||
@HistoryManager.pushUncompressedHistoryOps @project_id, @doc_id, @ops, 1, @callback
|
||||
@HistoryManager.recordAndFlushHistoryOps @project_id, @doc_id, @ops, 1, @callback
|
||||
|
||||
it "should push the ops into redis", ->
|
||||
@HistoryRedisManager.recordDocHasHistoryOps
|
||||
|
@ -65,7 +65,7 @@ describe "HistoryManager", ->
|
|||
beforeEach ->
|
||||
@HistoryRedisManager.recordDocHasHistoryOps =
|
||||
sinon.stub().callsArgWith(3, null)
|
||||
@HistoryManager.pushUncompressedHistoryOps @project_id, @doc_id, @ops, 2 * @HistoryManager.FLUSH_EVERY_N_OPS,@callback
|
||||
@HistoryManager.recordAndFlushHistoryOps @project_id, @doc_id, @ops, 2 * @HistoryManager.FLUSH_EVERY_N_OPS,@callback
|
||||
|
||||
it "should tell the track changes api to flush", ->
|
||||
@HistoryManager.flushDocChanges
|
||||
|
@ -77,7 +77,7 @@ describe "HistoryManager", ->
|
|||
@ops = ["op1", "op2", "op3"]
|
||||
@HistoryRedisManager.recordDocHasHistoryOps =
|
||||
sinon.stub().callsArgWith(3, null)
|
||||
@HistoryManager.pushUncompressedHistoryOps @project_id, @doc_id, @ops, 2 * @HistoryManager.FLUSH_EVERY_N_OPS + 1, @callback
|
||||
@HistoryManager.recordAndFlushHistoryOps @project_id, @doc_id, @ops, 2 * @HistoryManager.FLUSH_EVERY_N_OPS + 1, @callback
|
||||
|
||||
it "should tell the track changes api to flush", ->
|
||||
@HistoryManager.flushDocChanges
|
||||
|
@ -89,7 +89,7 @@ describe "HistoryManager", ->
|
|||
@HistoryRedisManager.recordDocHasHistoryOps =
|
||||
sinon.stub().callsArgWith(3, null)
|
||||
@HistoryManager.flushDocChanges = sinon.stub().callsArgWith(2, @error = new Error("oops"))
|
||||
@HistoryManager.pushUncompressedHistoryOps @project_id, @doc_id, @ops, 2 * @HistoryManager.FLUSH_EVERY_N_OPS, @callback
|
||||
@HistoryManager.recordAndFlushHistoryOps @project_id, @doc_id, @ops, 2 * @HistoryManager.FLUSH_EVERY_N_OPS, @callback
|
||||
|
||||
it "should log out the error", ->
|
||||
@logger.error
|
||||
|
@ -104,7 +104,7 @@ describe "HistoryManager", ->
|
|||
describe "with no ops", ->
|
||||
beforeEach ->
|
||||
@HistoryRedisManager.recordDocHasHistoryOps = sinon.stub().callsArgWith(3, null)
|
||||
@HistoryManager.pushUncompressedHistoryOps @project_id, @doc_id, [], 1, @callback
|
||||
@HistoryManager.recordAndFlushHistoryOps @project_id, @doc_id, [], 1, @callback
|
||||
|
||||
it "should not call HistoryRedisManager.recordDocHasHistoryOps", ->
|
||||
@HistoryRedisManager.recordDocHasHistoryOps.called.should.equal false
|
||||
|
|
|
@ -166,7 +166,7 @@ describe "UpdateManager", ->
|
|||
@ShareJsUpdateManager.applyUpdate = sinon.stub().yields(null, @updatedDocLines, @version, @appliedOps)
|
||||
@RedisManager.updateDocument = sinon.stub().yields()
|
||||
@RealTimeRedisManager.sendData = sinon.stub()
|
||||
@HistoryManager.pushUncompressedHistoryOps = sinon.stub().callsArg(4)
|
||||
@HistoryManager.recordAndFlushHistoryOps = sinon.stub().callsArg(4)
|
||||
|
||||
describe "normally", ->
|
||||
beforeEach ->
|
||||
|
@ -188,7 +188,7 @@ describe "UpdateManager", ->
|
|||
.should.equal true
|
||||
|
||||
it "should push the applied ops into the history queue", ->
|
||||
@HistoryManager.pushUncompressedHistoryOps
|
||||
@HistoryManager.recordAndFlushHistoryOps
|
||||
.calledWith(@project_id, @doc_id, @appliedOps)
|
||||
.should.equal true
|
||||
|
||||
|
|
Loading…
Reference in a new issue