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