Push ops into uncompressedHistoryOps list

This commit is contained in:
James Allen 2014-02-24 16:52:12 +00:00
parent 6f19f46d96
commit b13f70eadb
4 changed files with 25 additions and 4 deletions

View file

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

View file

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

View file

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

View file

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