mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-29 13:13:45 -05:00
add projectHistryId to project structure updates
This commit is contained in:
parent
a220794d32
commit
25c0be4eaa
10 changed files with 56 additions and 44 deletions
|
@ -161,13 +161,13 @@ module.exports = DocumentManager =
|
|||
return callback(error) if error?
|
||||
callback()
|
||||
|
||||
renameDoc: (project_id, doc_id, user_id, update, _callback = (error) ->) ->
|
||||
renameDoc: (project_id, doc_id, user_id, update, projectHistoryId, _callback = (error) ->) ->
|
||||
timer = new Metrics.Timer("docManager.updateProject")
|
||||
callback = (args...) ->
|
||||
timer.done()
|
||||
_callback(args...)
|
||||
|
||||
RedisManager.renameDoc project_id, doc_id, user_id, update, callback
|
||||
RedisManager.renameDoc project_id, doc_id, user_id, update, projectHistoryId, callback
|
||||
|
||||
getDocAndFlushIfOld: (project_id, doc_id, callback = (error, doc) ->) ->
|
||||
DocumentManager.getDoc project_id, doc_id, (error, lines, version, ranges, pathname, projectHistoryId, unflushedTime, alreadyLoaded) ->
|
||||
|
@ -223,9 +223,9 @@ module.exports = DocumentManager =
|
|||
UpdateManager = require "./UpdateManager"
|
||||
UpdateManager.lockUpdatesAndDo DocumentManager.deleteComment, project_id, doc_id, thread_id, callback
|
||||
|
||||
renameDocWithLock: (project_id, doc_id, user_id, update, callback = (error) ->) ->
|
||||
renameDocWithLock: (project_id, doc_id, user_id, update, projectHistoryId, callback = (error) ->) ->
|
||||
UpdateManager = require "./UpdateManager"
|
||||
UpdateManager.lockUpdatesAndDo DocumentManager.renameDoc, project_id, doc_id, user_id, update, callback
|
||||
UpdateManager.lockUpdatesAndDo DocumentManager.renameDoc, project_id, doc_id, user_id, update, projectHistoryId, callback
|
||||
|
||||
resyncDocContentsWithLock: (project_id, doc_id, callback = (error) ->) ->
|
||||
UpdateManager = require "./UpdateManager"
|
||||
|
|
|
@ -161,10 +161,10 @@ module.exports = HttpController =
|
|||
updateProject: (req, res, next = (error) ->) ->
|
||||
timer = new Metrics.Timer("http.updateProject")
|
||||
project_id = req.params.project_id
|
||||
{userId, docUpdates, fileUpdates, version} = req.body
|
||||
{projectHistoryId, userId, docUpdates, fileUpdates, version} = req.body
|
||||
logger.log {project_id, docUpdates, fileUpdates, version}, "updating project via http"
|
||||
|
||||
ProjectManager.updateProjectWithLocks project_id, userId, docUpdates, fileUpdates, version, (error) ->
|
||||
ProjectManager.updateProjectWithLocks project_id, projectHistoryId, userId, docUpdates, fileUpdates, version, (error) ->
|
||||
timer.done()
|
||||
return next(error) if error?
|
||||
logger.log project_id: project_id, "updated project via http"
|
||||
|
|
|
@ -7,7 +7,7 @@ module.exports = ProjectHistoryRedisManager =
|
|||
queueOps: (project_id, ops..., callback) ->
|
||||
rclient.rpush projectHistoryKeys.projectHistoryOps({project_id}), ops..., callback
|
||||
|
||||
queueRenameEntity: (project_id, entity_type, entity_id, user_id, projectUpdate, callback) ->
|
||||
queueRenameEntity: (project_id, projectHistoryId, entity_type, entity_id, user_id, projectUpdate, callback) ->
|
||||
projectUpdate =
|
||||
pathname: projectUpdate.pathname
|
||||
new_pathname: projectUpdate.newPathname
|
||||
|
@ -15,6 +15,7 @@ module.exports = ProjectHistoryRedisManager =
|
|||
user_id: user_id
|
||||
ts: new Date()
|
||||
version: projectUpdate.version
|
||||
projectHistoryId: projectHistoryId
|
||||
projectUpdate[entity_type] = entity_id
|
||||
|
||||
logger.log {project_id, projectUpdate}, "queue rename operation to project-history"
|
||||
|
@ -22,7 +23,7 @@ module.exports = ProjectHistoryRedisManager =
|
|||
|
||||
ProjectHistoryRedisManager.queueOps project_id, jsonUpdate, callback
|
||||
|
||||
queueAddEntity: (project_id, entity_type, entitiy_id, user_id, projectUpdate, callback = (error) ->) ->
|
||||
queueAddEntity: (project_id, projectHistoryId, entity_type, entitiy_id, user_id, projectUpdate, callback = (error) ->) ->
|
||||
projectUpdate =
|
||||
pathname: projectUpdate.pathname
|
||||
docLines: projectUpdate.docLines
|
||||
|
@ -31,6 +32,7 @@ module.exports = ProjectHistoryRedisManager =
|
|||
user_id: user_id
|
||||
ts: new Date()
|
||||
version: projectUpdate.version
|
||||
projectHistoryId: projectHistoryId
|
||||
projectUpdate[entity_type] = entitiy_id
|
||||
|
||||
logger.log {project_id, projectUpdate}, "queue add operation to project-history"
|
||||
|
|
|
@ -105,7 +105,7 @@ module.exports = ProjectManager =
|
|||
clearProjectState: (project_id, callback = (error) ->) ->
|
||||
RedisManager.clearProjectState project_id, callback
|
||||
|
||||
updateProjectWithLocks: (project_id, user_id, docUpdates, fileUpdates, version, _callback = (error) ->) ->
|
||||
updateProjectWithLocks: (project_id, projectHistoryId, user_id, docUpdates, fileUpdates, version, _callback = (error) ->) ->
|
||||
timer = new Metrics.Timer("projectManager.updateProject")
|
||||
callback = (args...) ->
|
||||
timer.done()
|
||||
|
@ -120,11 +120,11 @@ module.exports = ProjectManager =
|
|||
doc_id = projectUpdate.id
|
||||
projectUpdate.version = "#{project_version}.#{project_subversion++}"
|
||||
if projectUpdate.docLines?
|
||||
ProjectHistoryRedisManager.queueAddEntity project_id, 'doc', doc_id, user_id, projectUpdate, (error, count) ->
|
||||
ProjectHistoryRedisManager.queueAddEntity project_id, projectHistoryId, 'doc', doc_id, user_id, projectUpdate, (error, count) ->
|
||||
project_ops_length = count
|
||||
cb(error)
|
||||
else
|
||||
DocumentManager.renameDocWithLock project_id, doc_id, user_id, projectUpdate, (error, count) ->
|
||||
DocumentManager.renameDocWithLock project_id, doc_id, user_id, projectUpdate, projectHistoryId, (error, count) ->
|
||||
project_ops_length = count
|
||||
cb(error)
|
||||
|
||||
|
@ -132,11 +132,11 @@ module.exports = ProjectManager =
|
|||
file_id = projectUpdate.id
|
||||
projectUpdate.version = "#{project_version}.#{project_subversion++}"
|
||||
if projectUpdate.url?
|
||||
ProjectHistoryRedisManager.queueAddEntity project_id, 'file', file_id, user_id, projectUpdate, (error, count) ->
|
||||
ProjectHistoryRedisManager.queueAddEntity project_id, projectHistoryId, 'file', file_id, user_id, projectUpdate, (error, count) ->
|
||||
project_ops_length = count
|
||||
cb(error)
|
||||
else
|
||||
ProjectHistoryRedisManager.queueRenameEntity project_id, 'file', file_id, user_id, projectUpdate, (error, count) ->
|
||||
ProjectHistoryRedisManager.queueRenameEntity project_id, projectHistoryId, 'file', file_id, user_id, projectUpdate, (error, count) ->
|
||||
project_ops_length = count
|
||||
cb(error)
|
||||
|
||||
|
|
|
@ -275,16 +275,16 @@ module.exports = RedisManager =
|
|||
else
|
||||
callback null, docUpdateCount
|
||||
|
||||
renameDoc: (project_id, doc_id, user_id, update, callback = (error) ->) ->
|
||||
renameDoc: (project_id, doc_id, user_id, update, projectHistoryId, callback = (error) ->) ->
|
||||
RedisManager.getDoc project_id, doc_id, (error, lines, version) ->
|
||||
return callback(error) if error?
|
||||
|
||||
if lines? and version?
|
||||
rclient.set keys.pathname(doc_id:doc_id), update.newPathname, (error) ->
|
||||
return callback(error) if error?
|
||||
ProjectHistoryRedisManager.queueRenameEntity project_id, 'doc', doc_id, user_id, update, callback
|
||||
ProjectHistoryRedisManager.queueRenameEntity project_id, projectHistoryId, 'doc', doc_id, user_id, update, callback
|
||||
else
|
||||
ProjectHistoryRedisManager.queueRenameEntity project_id, 'doc', doc_id, user_id, update, callback
|
||||
ProjectHistoryRedisManager.queueRenameEntity project_id, projectHistoryId, 'doc', doc_id, user_id, update, callback
|
||||
|
||||
clearUnflushedTime: (doc_id, callback = (error) ->) ->
|
||||
rclient.del keys.unflushedTime(doc_id:doc_id), callback
|
||||
|
|
|
@ -25,6 +25,7 @@ describe "DocumentManager", ->
|
|||
"./UpdateManager": @UpdateManager = {}
|
||||
"./RangesManager": @RangesManager = {}
|
||||
@project_id = "project-id-123"
|
||||
@projectHistoryId = "history-id-123"
|
||||
@doc_id = "doc-id-123"
|
||||
@user_id = 1234
|
||||
@callback = sinon.stub()
|
||||
|
@ -459,11 +460,11 @@ describe "DocumentManager", ->
|
|||
|
||||
describe "successfully", ->
|
||||
beforeEach ->
|
||||
@DocumentManager.renameDoc @project_id, @doc_id, @user_id, @update, @callback
|
||||
@DocumentManager.renameDoc @project_id, @doc_id, @user_id, @update, @projectHistoryId, @callback
|
||||
|
||||
it "should rename the document", ->
|
||||
@RedisManager.renameDoc
|
||||
.calledWith(@project_id, @doc_id, @user_id, @update)
|
||||
.calledWith(@project_id, @doc_id, @user_id, @update, @projectHistoryId)
|
||||
.should.equal true
|
||||
|
||||
it "should call the callback", ->
|
||||
|
|
|
@ -509,23 +509,24 @@ describe "HttpController", ->
|
|||
|
||||
describe "updateProject", ->
|
||||
beforeEach ->
|
||||
@projectHistoryId = "history-id-123"
|
||||
@userId = "user-id-123"
|
||||
@docUpdates = sinon.stub()
|
||||
@fileUpdates = sinon.stub()
|
||||
@version = 1234567
|
||||
@req =
|
||||
body: {@userId, @docUpdates, @fileUpdates, @version}
|
||||
body: {@projectHistoryId, @userId, @docUpdates, @fileUpdates, @version}
|
||||
params:
|
||||
project_id: @project_id
|
||||
|
||||
describe "successfully", ->
|
||||
beforeEach ->
|
||||
@ProjectManager.updateProjectWithLocks = sinon.stub().callsArgWith(5)
|
||||
@ProjectManager.updateProjectWithLocks = sinon.stub().callsArgWith(6)
|
||||
@HttpController.updateProject(@req, @res, @next)
|
||||
|
||||
it "should accept the change", ->
|
||||
@ProjectManager.updateProjectWithLocks
|
||||
.calledWith(@project_id, @userId, @docUpdates, @fileUpdates, @version)
|
||||
.calledWith(@project_id, @projectHistoryId, @userId, @docUpdates, @fileUpdates, @version)
|
||||
.should.equal true
|
||||
|
||||
it "should return a successful No Content response", ->
|
||||
|
@ -538,7 +539,7 @@ describe "HttpController", ->
|
|||
|
||||
describe "when an errors occurs", ->
|
||||
beforeEach ->
|
||||
@ProjectManager.updateProjectWithLocks = sinon.stub().callsArgWith(5, new Error("oops"))
|
||||
@ProjectManager.updateProjectWithLocks = sinon.stub().callsArgWith(6, new Error("oops"))
|
||||
@HttpController.updateProject(@req, @res, @next)
|
||||
|
||||
it "should call next with the error", ->
|
||||
|
|
|
@ -8,6 +8,7 @@ tk = require "timekeeper"
|
|||
describe "ProjectHistoryRedisManager", ->
|
||||
beforeEach ->
|
||||
@project_id = "project-id-123"
|
||||
@projectHistoryId = "history-id-123"
|
||||
@user_id = "user-id-123"
|
||||
@callback = sinon.stub()
|
||||
@rclient = {}
|
||||
|
@ -50,9 +51,10 @@ describe "ProjectHistoryRedisManager", ->
|
|||
@rawUpdate =
|
||||
pathname: @pathname = '/old'
|
||||
newPathname: @newPathname = '/new'
|
||||
version: @version = 2
|
||||
|
||||
@ProjectHistoryRedisManager.queueOps = sinon.stub()
|
||||
@ProjectHistoryRedisManager.queueRenameEntity @project_id, 'file', @file_id, @user_id, @rawUpdate, @callback
|
||||
@ProjectHistoryRedisManager.queueRenameEntity @project_id, @projectHistoryId, 'file', @file_id, @user_id, @rawUpdate, @callback
|
||||
|
||||
it "should queue an update", ->
|
||||
update =
|
||||
|
@ -61,6 +63,8 @@ describe "ProjectHistoryRedisManager", ->
|
|||
meta:
|
||||
user_id: @user_id
|
||||
ts: new Date()
|
||||
version: @version
|
||||
projectHistoryId: @projectHistoryId
|
||||
file: @file_id
|
||||
|
||||
@ProjectHistoryRedisManager.queueOps
|
||||
|
@ -75,10 +79,11 @@ describe "ProjectHistoryRedisManager", ->
|
|||
@rawUpdate =
|
||||
pathname: @pathname = '/old'
|
||||
docLines: @docLines = 'a\nb'
|
||||
version: @version = 2
|
||||
url: @url = 'filestore.example.com'
|
||||
|
||||
@ProjectHistoryRedisManager.queueOps = sinon.stub()
|
||||
@ProjectHistoryRedisManager.queueAddEntity @project_id, 'doc', @doc_id, @user_id, @rawUpdate, @callback
|
||||
@ProjectHistoryRedisManager.queueAddEntity @project_id, @projectHistoryId, 'doc', @doc_id, @user_id, @rawUpdate, @callback
|
||||
|
||||
it "should queue an update", ->
|
||||
update =
|
||||
|
@ -88,6 +93,8 @@ describe "ProjectHistoryRedisManager", ->
|
|||
meta:
|
||||
user_id: @user_id
|
||||
ts: new Date()
|
||||
version: @version
|
||||
projectHistoryId: @projectHistoryId
|
||||
doc: @doc_id
|
||||
|
||||
@ProjectHistoryRedisManager.queueOps
|
||||
|
|
|
@ -18,6 +18,7 @@ describe "ProjectManager", ->
|
|||
done: sinon.stub()
|
||||
|
||||
@project_id = "project-id-123"
|
||||
@projectHistoryId = 'history-id-123'
|
||||
@user_id = "user-id-123"
|
||||
@version = 1234567
|
||||
@HistoryManager.shouldFlushHistoryOps = sinon.stub().returns(false)
|
||||
|
@ -27,7 +28,6 @@ describe "ProjectManager", ->
|
|||
describe "updateProjectWithLocks", ->
|
||||
describe "rename operations", ->
|
||||
beforeEach ->
|
||||
|
||||
@firstDocUpdate =
|
||||
id: 1
|
||||
pathname: 'foo'
|
||||
|
@ -47,22 +47,22 @@ describe "ProjectManager", ->
|
|||
|
||||
describe "successfully", ->
|
||||
beforeEach ->
|
||||
@ProjectManager.updateProjectWithLocks @project_id, @user_id, @docUpdates, @fileUpdates, @version, @callback
|
||||
@ProjectManager.updateProjectWithLocks @project_id, @projectHistoryId, @user_id, @docUpdates, @fileUpdates, @version, @callback
|
||||
|
||||
it "should rename the docs in the updates", ->
|
||||
firstDocUpdateWithVersion = _.extend({}, @firstDocUpdate, {version: "#{@version}.0"})
|
||||
secondDocUpdateWithVersion = _.extend({}, @secondDocUpdate, {version: "#{@version}.1"})
|
||||
@DocumentManager.renameDocWithLock
|
||||
.calledWith(@project_id, @firstDocUpdate.id, @user_id, firstDocUpdateWithVersion)
|
||||
.calledWith(@project_id, @firstDocUpdate.id, @user_id, firstDocUpdateWithVersion, @projectHistoryId)
|
||||
.should.equal true
|
||||
@DocumentManager.renameDocWithLock
|
||||
.calledWith(@project_id, @secondDocUpdate.id, @user_id, secondDocUpdateWithVersion)
|
||||
.calledWith(@project_id, @secondDocUpdate.id, @user_id, secondDocUpdateWithVersion, @projectHistoryId)
|
||||
.should.equal true
|
||||
|
||||
it "should rename the files in the updates", ->
|
||||
firstFileUpdateWithVersion = _.extend({}, @firstFileUpdate, {version: "#{@version}.2"})
|
||||
@ProjectHistoryRedisManager.queueRenameEntity
|
||||
.calledWith(@project_id, 'file', @firstFileUpdate.id, @user_id, firstFileUpdateWithVersion)
|
||||
.calledWith(@project_id, @projectHistoryId, 'file', @firstFileUpdate.id, @user_id, firstFileUpdateWithVersion)
|
||||
.should.equal true
|
||||
|
||||
it "should not flush the history", ->
|
||||
|
@ -77,7 +77,7 @@ describe "ProjectManager", ->
|
|||
beforeEach ->
|
||||
@error = new Error('error')
|
||||
@DocumentManager.renameDocWithLock = sinon.stub().yields(@error)
|
||||
@ProjectManager.updateProjectWithLocks @project_id, @user_id, @docUpdates, @fileUpdates, @version, @callback
|
||||
@ProjectManager.updateProjectWithLocks @project_id, @projectHistoryId, @user_id, @docUpdates, @fileUpdates, @version, @callback
|
||||
|
||||
it "should call the callback with the error", ->
|
||||
@callback.calledWith(@error).should.equal true
|
||||
|
@ -86,7 +86,7 @@ describe "ProjectManager", ->
|
|||
beforeEach ->
|
||||
@error = new Error('error')
|
||||
@ProjectHistoryRedisManager.queueRenameEntity = sinon.stub().yields(@error)
|
||||
@ProjectManager.updateProjectWithLocks @project_id, @user_id, @docUpdates, @fileUpdates, @version, @callback
|
||||
@ProjectManager.updateProjectWithLocks @project_id, @projectHistoryId, @user_id, @docUpdates, @fileUpdates, @version, @callback
|
||||
|
||||
it "should call the callback with the error", ->
|
||||
@callback.calledWith(@error).should.equal true
|
||||
|
@ -94,7 +94,7 @@ describe "ProjectManager", ->
|
|||
describe "with enough ops to flush", ->
|
||||
beforeEach ->
|
||||
@HistoryManager.shouldFlushHistoryOps = sinon.stub().returns(true)
|
||||
@ProjectManager.updateProjectWithLocks @project_id, @user_id, @docUpdates, @fileUpdates, @version, @callback
|
||||
@ProjectManager.updateProjectWithLocks @project_id, @projectHistoryId, @user_id, @docUpdates, @fileUpdates, @version, @callback
|
||||
|
||||
it "should flush the history", ->
|
||||
@HistoryManager.flushProjectChangesAsync
|
||||
|
@ -121,26 +121,26 @@ describe "ProjectManager", ->
|
|||
|
||||
describe "successfully", ->
|
||||
beforeEach ->
|
||||
@ProjectManager.updateProjectWithLocks @project_id, @user_id, @docUpdates, @fileUpdates, @version, @callback
|
||||
@ProjectManager.updateProjectWithLocks @project_id, @projectHistoryId, @user_id, @docUpdates, @fileUpdates, @version, @callback
|
||||
|
||||
it "should add the docs in the updates", ->
|
||||
firstDocUpdateWithVersion = _.extend({}, @firstDocUpdate, {version: "#{@version}.0"})
|
||||
secondDocUpdateWithVersion = _.extend({}, @secondDocUpdate, {version: "#{@version}.1"})
|
||||
@ProjectHistoryRedisManager.queueAddEntity.getCall(0)
|
||||
.calledWith(@project_id, 'doc', @firstDocUpdate.id, @user_id, firstDocUpdateWithVersion)
|
||||
.calledWith(@project_id, @projectHistoryId, 'doc', @firstDocUpdate.id, @user_id, firstDocUpdateWithVersion)
|
||||
.should.equal true
|
||||
@ProjectHistoryRedisManager.queueAddEntity.getCall(1)
|
||||
.calledWith(@project_id, 'doc', @secondDocUpdate.id, @user_id, secondDocUpdateWithVersion)
|
||||
.calledWith(@project_id, @projectHistoryId, 'doc', @secondDocUpdate.id, @user_id, secondDocUpdateWithVersion)
|
||||
.should.equal true
|
||||
|
||||
it "should add the files in the updates", ->
|
||||
firstFileUpdateWithVersion = _.extend({}, @firstFileUpdate, {version: "#{@version}.2"})
|
||||
secondFileUpdateWithVersion = _.extend({}, @secondFileUpdate, {version: "#{@version}.3"})
|
||||
@ProjectHistoryRedisManager.queueAddEntity.getCall(2)
|
||||
.calledWith(@project_id, 'file', @firstFileUpdate.id, @user_id, firstFileUpdateWithVersion)
|
||||
.calledWith(@project_id, @projectHistoryId, 'file', @firstFileUpdate.id, @user_id, firstFileUpdateWithVersion)
|
||||
.should.equal true
|
||||
@ProjectHistoryRedisManager.queueAddEntity.getCall(3)
|
||||
.calledWith(@project_id, 'file', @secondFileUpdate.id, @user_id, secondFileUpdateWithVersion)
|
||||
.calledWith(@project_id, @projectHistoryId, 'file', @secondFileUpdate.id, @user_id, secondFileUpdateWithVersion)
|
||||
.should.equal true
|
||||
|
||||
it "should not flush the history", ->
|
||||
|
@ -155,7 +155,7 @@ describe "ProjectManager", ->
|
|||
beforeEach ->
|
||||
@error = new Error('error')
|
||||
@ProjectHistoryRedisManager.queueAddEntity = sinon.stub().yields(@error)
|
||||
@ProjectManager.updateProjectWithLocks @project_id, @user_id, @docUpdates, @fileUpdates, @version, @callback
|
||||
@ProjectManager.updateProjectWithLocks @project_id, @projectHistoryId, @user_id, @docUpdates, @fileUpdates, @version, @callback
|
||||
|
||||
it "should call the callback with the error", ->
|
||||
@callback.calledWith(@error).should.equal true
|
||||
|
@ -164,7 +164,7 @@ describe "ProjectManager", ->
|
|||
beforeEach ->
|
||||
@error = new Error('error')
|
||||
@ProjectHistoryRedisManager.queueAddEntity = sinon.stub().yields(@error)
|
||||
@ProjectManager.updateProjectWithLocks @project_id, @user_id, @docUpdates, @fileUpdates, @version, @callback
|
||||
@ProjectManager.updateProjectWithLocks @project_id, @projectHistoryId, @user_id, @docUpdates, @fileUpdates, @version, @callback
|
||||
|
||||
it "should call the callback with the error", ->
|
||||
@callback.calledWith(@error).should.equal true
|
||||
|
@ -172,7 +172,7 @@ describe "ProjectManager", ->
|
|||
describe "with enough ops to flush", ->
|
||||
beforeEach ->
|
||||
@HistoryManager.shouldFlushHistoryOps = sinon.stub().returns(true)
|
||||
@ProjectManager.updateProjectWithLocks @project_id, @user_id, @docUpdates, @fileUpdates, @version, @callback
|
||||
@ProjectManager.updateProjectWithLocks @project_id, @projectHistoryId, @user_id, @docUpdates, @fileUpdates, @version, @callback
|
||||
|
||||
it "should flush the history", ->
|
||||
@HistoryManager.flushProjectChangesAsync
|
||||
|
|
|
@ -60,6 +60,7 @@ describe "RedisManager", ->
|
|||
|
||||
@doc_id = "doc-id-123"
|
||||
@project_id = "project-id-123"
|
||||
@projectHistoryId = "history-id-123"
|
||||
@callback = sinon.stub()
|
||||
|
||||
describe "getDoc", ->
|
||||
|
@ -703,7 +704,7 @@ describe "RedisManager", ->
|
|||
beforeEach ->
|
||||
@RedisManager.getDoc = sinon.stub().callsArgWith(2, null, 'lines', 'version')
|
||||
@ProjectHistoryRedisManager.queueRenameEntity = sinon.stub().yields()
|
||||
@RedisManager.renameDoc @project_id, @doc_id, @userId, @update, @callback
|
||||
@RedisManager.renameDoc @project_id, @doc_id, @userId, @update, @projectHistoryId, @callback
|
||||
|
||||
it "update the cached pathname", ->
|
||||
@rclient.set
|
||||
|
@ -712,19 +713,19 @@ describe "RedisManager", ->
|
|||
|
||||
it "should queue an update", ->
|
||||
@ProjectHistoryRedisManager.queueRenameEntity
|
||||
.calledWithExactly(@project_id, 'doc', @doc_id, @userId, @update, @callback)
|
||||
.calledWithExactly(@project_id, @projectHistoryId, 'doc', @doc_id, @userId, @update, @callback)
|
||||
.should.equal true
|
||||
|
||||
describe "the document is not cached in redis", ->
|
||||
beforeEach ->
|
||||
@RedisManager.getDoc = sinon.stub().callsArgWith(2, null, null, null)
|
||||
@ProjectHistoryRedisManager.queueRenameEntity = sinon.stub().yields()
|
||||
@RedisManager.renameDoc @project_id, @doc_id, @userId, @update, @callback
|
||||
@RedisManager.renameDoc @project_id, @doc_id, @userId, @update, @projectHistoryId, @callback
|
||||
|
||||
it "does not update the cached pathname", ->
|
||||
@rclient.set.called.should.equal false
|
||||
|
||||
it "should queue an update", ->
|
||||
@ProjectHistoryRedisManager.queueRenameEntity
|
||||
.calledWithExactly(@project_id, 'doc', @doc_id, @userId, @update, @callback)
|
||||
.calledWithExactly(@project_id, @projectHistoryId, 'doc', @doc_id, @userId, @update, @callback)
|
||||
.should.equal true
|
||||
|
|
Loading…
Reference in a new issue