|
|
@@ -25,7 +25,6 @@ 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()
|
|
|
@@ -112,7 +111,7 @@ describe "DocumentManager", ->
|
|
|
describe "getDocAndRecentOps", ->
|
|
|
describe "with a previous version specified", ->
|
|
|
beforeEach ->
|
|
|
- @DocumentManager.getDoc = sinon.stub().callsArgWith(2, null, @lines, @version, @ranges, @pathname, @projectHistoryId)
|
|
|
+ @DocumentManager.getDoc = sinon.stub().callsArgWith(2, null, @lines, @version, @ranges, @pathname)
|
|
|
@RedisManager.getPreviousDocOps = sinon.stub().callsArgWith(3, null, @ops)
|
|
|
@DocumentManager.getDocAndRecentOps @project_id, @doc_id, @fromVersion, @callback
|
|
|
|
|
|
@@ -127,14 +126,14 @@ describe "DocumentManager", ->
|
|
|
.should.equal true
|
|
|
|
|
|
it "should call the callback with the doc info", ->
|
|
|
- @callback.calledWith(null, @lines, @version, @ops, @ranges, @pathname, @projectHistoryId).should.equal true
|
|
|
+ @callback.calledWith(null, @lines, @version, @ops, @ranges, @pathname).should.equal true
|
|
|
|
|
|
it "should time the execution", ->
|
|
|
@Metrics.Timer::done.called.should.equal true
|
|
|
|
|
|
describe "with no previous version specified", ->
|
|
|
beforeEach ->
|
|
|
- @DocumentManager.getDoc = sinon.stub().callsArgWith(2, null, @lines, @version, @ranges, @pathname, @projectHistoryId)
|
|
|
+ @DocumentManager.getDoc = sinon.stub().callsArgWith(2, null, @lines, @version, @ranges, @pathname)
|
|
|
@RedisManager.getPreviousDocOps = sinon.stub().callsArgWith(3, null, @ops)
|
|
|
@DocumentManager.getDocAndRecentOps @project_id, @doc_id, -1, @callback
|
|
|
|
|
|
@@ -147,7 +146,7 @@ describe "DocumentManager", ->
|
|
|
@RedisManager.getPreviousDocOps.called.should.equal false
|
|
|
|
|
|
it "should call the callback with the doc info", ->
|
|
|
- @callback.calledWith(null, @lines, @version, [], @ranges, @pathname, @projectHistoryId).should.equal true
|
|
|
+ @callback.calledWith(null, @lines, @version, [], @ranges, @pathname).should.equal true
|
|
|
|
|
|
it "should time the execution", ->
|
|
|
@Metrics.Timer::done.called.should.equal true
|
|
|
@@ -155,7 +154,7 @@ describe "DocumentManager", ->
|
|
|
describe "getDoc", ->
|
|
|
describe "when the doc exists in Redis", ->
|
|
|
beforeEach ->
|
|
|
- @RedisManager.getDoc = sinon.stub().callsArgWith(2, null, @lines, @version, @ranges, @pathname, @projectHistoryId, @unflushedTime)
|
|
|
+ @RedisManager.getDoc = sinon.stub().callsArgWith(2, null, @lines, @version, @ranges, @pathname, @unflushedTime)
|
|
|
@DocumentManager.getDoc @project_id, @doc_id, @callback
|
|
|
|
|
|
it "should get the doc from Redis", ->
|
|
|
@@ -164,7 +163,7 @@ describe "DocumentManager", ->
|
|
|
.should.equal true
|
|
|
|
|
|
it "should call the callback with the doc info", ->
|
|
|
- @callback.calledWith(null, @lines, @version, @ranges, @pathname, @projectHistoryId, @unflushedTime, true).should.equal true
|
|
|
+ @callback.calledWith(null, @lines, @version, @ranges, @pathname, @unflushedTime, true).should.equal true
|
|
|
|
|
|
it "should time the execution", ->
|
|
|
@Metrics.Timer::done.called.should.equal true
|
|
|
@@ -172,7 +171,7 @@ describe "DocumentManager", ->
|
|
|
describe "when the doc does not exist in Redis", ->
|
|
|
beforeEach ->
|
|
|
@RedisManager.getDoc = sinon.stub().callsArgWith(2, null, null, null, null, null, null)
|
|
|
- @PersistenceManager.getDoc = sinon.stub().callsArgWith(2, null, @lines, @version, @ranges, @pathname, @projectHistoryId)
|
|
|
+ @PersistenceManager.getDoc = sinon.stub().callsArgWith(2, null, @lines, @version, @ranges, @pathname)
|
|
|
@RedisManager.putDocInMemory = sinon.stub().yields()
|
|
|
@DocumentManager.getDoc @project_id, @doc_id, @callback
|
|
|
|
|
|
@@ -188,11 +187,11 @@ describe "DocumentManager", ->
|
|
|
|
|
|
it "should set the doc in Redis", ->
|
|
|
@RedisManager.putDocInMemory
|
|
|
- .calledWith(@project_id, @doc_id, @lines, @version, @ranges, @pathname, @projectHistoryId)
|
|
|
+ .calledWith(@project_id, @doc_id, @lines, @version, @ranges, @pathname)
|
|
|
.should.equal true
|
|
|
|
|
|
it "should call the callback with the doc info", ->
|
|
|
- @callback.calledWith(null, @lines, @version, @ranges, @pathname, @projectHistoryId, null, false).should.equal true
|
|
|
+ @callback.calledWith(null, @lines, @version, @ranges, @pathname, null, false).should.equal true
|
|
|
|
|
|
it "should time the execution", ->
|
|
|
@Metrics.Timer::done.called.should.equal true
|
|
|
@@ -203,7 +202,7 @@ describe "DocumentManager", ->
|
|
|
@beforeLines = ["before", "lines"]
|
|
|
@afterLines = ["after", "lines"]
|
|
|
@ops = [{ i: "foo", p: 4 }, { d: "bar", p: 42 }]
|
|
|
- @DocumentManager.getDoc = sinon.stub().callsArgWith(2, null, @beforeLines, @version, @ranges, @pathname, @projectHistoryId, @unflushedTime, true)
|
|
|
+ @DocumentManager.getDoc = sinon.stub().callsArgWith(2, null, @beforeLines, @version, @ranges, @pathname, @unflushedTime, true)
|
|
|
@DiffCodec.diffAsShareJsOp = sinon.stub().callsArgWith(2, null, @ops)
|
|
|
@UpdateManager.applyUpdate = sinon.stub().callsArgWith(3, null)
|
|
|
@DocumentManager.flushDocIfLoaded = sinon.stub().callsArg(2)
|
|
|
@@ -403,7 +402,7 @@ describe "DocumentManager", ->
|
|
|
describe "when the doc is in Redis", ->
|
|
|
describe "and has changes to be flushed", ->
|
|
|
beforeEach ->
|
|
|
- @DocumentManager.getDoc = sinon.stub().callsArgWith(2, null, @lines, @version, @ranges, @projectHistoryId, @pathname, Date.now() - 1e9, true)
|
|
|
+ @DocumentManager.getDoc = sinon.stub().callsArgWith(2, null, @lines, @version, @ranges, @pathname, Date.now() - 1e9, true)
|
|
|
@DocumentManager.getDocAndFlushIfOld @project_id, @doc_id, @callback
|
|
|
|
|
|
it "should get the doc", ->
|
|
|
@@ -460,11 +459,11 @@ describe "DocumentManager", ->
|
|
|
|
|
|
describe "successfully", ->
|
|
|
beforeEach ->
|
|
|
- @DocumentManager.renameDoc @project_id, @doc_id, @user_id, @update, @projectHistoryId, @callback
|
|
|
+ @DocumentManager.renameDoc @project_id, @doc_id, @user_id, @update, @callback
|
|
|
|
|
|
it "should rename the document", ->
|
|
|
@RedisManager.renameDoc
|
|
|
- .calledWith(@project_id, @doc_id, @user_id, @update, @projectHistoryId)
|
|
|
+ .calledWith(@project_id, @doc_id, @user_id, @update)
|
|
|
.should.equal true
|
|
|
|
|
|
it "should call the callback", ->
|
|
|
@@ -473,7 +472,7 @@ describe "DocumentManager", ->
|
|
|
describe "resyncDocContents", ->
|
|
|
describe "when doc is loaded in redis", ->
|
|
|
beforeEach ->
|
|
|
- @RedisManager.getDoc = sinon.stub().callsArgWith(2, null, @lines, @version, @ranges, @pathname, @projectHistoryId)
|
|
|
+ @RedisManager.getDoc = sinon.stub().callsArgWith(2, null, @lines, @version, @ranges, @pathname)
|
|
|
@ProjectHistoryRedisManager.queueResyncDocContent = sinon.stub()
|
|
|
@DocumentManager.resyncDocContents @project_id, @doc_id, @callback
|
|
|
|
|
|
@@ -484,13 +483,13 @@ describe "DocumentManager", ->
|
|
|
|
|
|
it "queues a resync doc content update", ->
|
|
|
@ProjectHistoryRedisManager.queueResyncDocContent
|
|
|
- .calledWith(@project_id, @projectHistoryId, @doc_id, @lines, @version, @pathname, @callback)
|
|
|
+ .calledWith(@project_id, @doc_id, @lines, @version, @pathname, @callback)
|
|
|
.should.equal true
|
|
|
|
|
|
describe "when doc is not loaded in redis", ->
|
|
|
beforeEach ->
|
|
|
@RedisManager.getDoc = sinon.stub().callsArgWith(2, null)
|
|
|
- @PersistenceManager.getDoc = sinon.stub().callsArgWith(2, null, @lines, @version, @ranges, @pathname, @projectHistoryId)
|
|
|
+ @PersistenceManager.getDoc = sinon.stub().callsArgWith(2, null, @lines, @version, @ranges, @pathname)
|
|
|
@ProjectHistoryRedisManager.queueResyncDocContent = sinon.stub()
|
|
|
@DocumentManager.resyncDocContents @project_id, @doc_id, @callback
|
|
|
|
|
|
@@ -506,5 +505,5 @@ describe "DocumentManager", ->
|
|
|
|
|
|
it "queues a resync doc content update", ->
|
|
|
@ProjectHistoryRedisManager.queueResyncDocContent
|
|
|
- .calledWith(@project_id, @projectHistoryId, @doc_id, @lines, @version, @pathname, @callback)
|
|
|
+ .calledWith(@project_id, @doc_id, @lines, @version, @pathname, @callback)
|
|
|
.should.equal true
|