|
|
@@ -265,506 +265,506 @@ describe "UpdatesManager", ->
|
|
|
it "should call the callback", ->
|
|
|
@callback.called.should.equal true
|
|
|
|
|
|
- describe "getDocUpdates", ->
|
|
|
- beforeEach ->
|
|
|
- @updates = ["mock-updates"]
|
|
|
- @options = { to: "mock-to", limit: "mock-limit" }
|
|
|
- @MongoManager.getDocUpdates = sinon.stub().callsArgWith(2, null, @updates)
|
|
|
- @UpdatesManager.processUncompressedUpdatesWithLock = sinon.stub().callsArg(2)
|
|
|
- @UpdatesManager.getDocUpdates @project_id, @doc_id, @options, @callback
|
|
|
-
|
|
|
- it "should process outstanding updates", ->
|
|
|
- @UpdatesManager.processUncompressedUpdatesWithLock
|
|
|
- .calledWith(@project_id, @doc_id)
|
|
|
- .should.equal true
|
|
|
-
|
|
|
- it "should get the updates from the database", ->
|
|
|
- @MongoManager.getDocUpdates
|
|
|
- .calledWith(@doc_id, @options)
|
|
|
- .should.equal true
|
|
|
-
|
|
|
- it "should return the updates", ->
|
|
|
- @callback
|
|
|
- .calledWith(null, @updates)
|
|
|
- .should.equal true
|
|
|
-
|
|
|
- describe "getDocUpdatesWithUserInfo", ->
|
|
|
- beforeEach ->
|
|
|
- @updates = ["mock-updates"]
|
|
|
- @options = { to: "mock-to", limit: "mock-limit" }
|
|
|
- @updatesWithUserInfo = ["updates-with-user-info"]
|
|
|
- @UpdatesManager.getDocUpdates = sinon.stub().callsArgWith(3, null, @updates)
|
|
|
- @UpdatesManager.fillUserInfo = sinon.stub().callsArgWith(1, null, @updatesWithUserInfo)
|
|
|
- @UpdatesManager.getDocUpdatesWithUserInfo @project_id, @doc_id, @options, @callback
|
|
|
-
|
|
|
- it "should get the updates", ->
|
|
|
- @UpdatesManager.getDocUpdates
|
|
|
- .calledWith(@project_id, @doc_id, @options)
|
|
|
- .should.equal true
|
|
|
-
|
|
|
- it "should file the updates with the user info", ->
|
|
|
- @UpdatesManager.fillUserInfo
|
|
|
- .calledWith(@updates)
|
|
|
- .should.equal true
|
|
|
-
|
|
|
- it "should return the updates with the filled details", ->
|
|
|
- @callback.calledWith(null, @updatesWithUserInfo).should.equal true
|
|
|
-
|
|
|
- describe "getProjectUpdates", ->
|
|
|
- beforeEach ->
|
|
|
- @updates = ["mock-updates"]
|
|
|
- @options = { before: "mock-before", limit: "mock-limit" }
|
|
|
- @MongoManager.getProjectUpdates = sinon.stub().callsArgWith(2, null, @updates)
|
|
|
- @UpdatesManager.processUncompressedUpdatesForProject = sinon.stub().callsArg(1)
|
|
|
- @UpdatesManager.getProjectUpdates @project_id, @options, @callback
|
|
|
-
|
|
|
- it "should process any outstanding updates", ->
|
|
|
- @UpdatesManager.processUncompressedUpdatesForProject
|
|
|
- .calledWith(@project_id)
|
|
|
- .should.equal true
|
|
|
-
|
|
|
- it "should get the updates from the database", ->
|
|
|
- @MongoManager.getProjectUpdates
|
|
|
- .calledWith(@project_id, @options)
|
|
|
- .should.equal true
|
|
|
-
|
|
|
- it "should return the updates", ->
|
|
|
- @callback
|
|
|
- .calledWith(null, @updates)
|
|
|
- .should.equal true
|
|
|
-
|
|
|
- describe "processUncompressedUpdatesForProject", ->
|
|
|
- beforeEach (done) ->
|
|
|
- @doc_ids = ["mock-id-1", "mock-id-2"]
|
|
|
- @UpdatesManager.processUncompressedUpdatesWithLock = sinon.stub().callsArg(2)
|
|
|
- @RedisManager.getDocIdsWithHistoryOps = sinon.stub().callsArgWith(1, null, @doc_ids)
|
|
|
- @UpdatesManager.processUncompressedUpdatesForProject @project_id, () =>
|
|
|
- @callback()
|
|
|
- done()
|
|
|
-
|
|
|
- it "should get all the docs with history ops", ->
|
|
|
- @RedisManager.getDocIdsWithHistoryOps
|
|
|
- .calledWith(@project_id)
|
|
|
- .should.equal true
|
|
|
-
|
|
|
- it "should process the doc ops for the each doc_id", ->
|
|
|
- for doc_id in @doc_ids
|
|
|
- @UpdatesManager.processUncompressedUpdatesWithLock
|
|
|
- .calledWith(@project_id, doc_id)
|
|
|
- .should.equal true
|
|
|
-
|
|
|
- it "should call the callback", ->
|
|
|
- @callback.called.should.equal true
|
|
|
-
|
|
|
- describe "getProjectUpdatesWithUserInfo", ->
|
|
|
- beforeEach ->
|
|
|
- @updates = ["mock-updates"]
|
|
|
- @options = { before: "mock-before", limit: "mock-limit" }
|
|
|
- @updatesWithUserInfo = ["updates-with-user-info"]
|
|
|
- @UpdatesManager.getProjectUpdates = sinon.stub().callsArgWith(2, null, @updates)
|
|
|
- @UpdatesManager.fillUserInfo = sinon.stub().callsArgWith(1, null, @updatesWithUserInfo)
|
|
|
- @UpdatesManager.getProjectUpdatesWithUserInfo @project_id, @options, @callback
|
|
|
-
|
|
|
- it "should get the updates", ->
|
|
|
- @UpdatesManager.getProjectUpdates
|
|
|
- .calledWith(@project_id, @options)
|
|
|
- .should.equal true
|
|
|
-
|
|
|
- it "should file the updates with the user info", ->
|
|
|
- @UpdatesManager.fillUserInfo
|
|
|
- .calledWith(@updates)
|
|
|
- .should.equal true
|
|
|
-
|
|
|
- it "should return the updates with the filled details", ->
|
|
|
- @callback.calledWith(null, @updatesWithUserInfo).should.equal true
|
|
|
-
|
|
|
- describe "_extendBatchOfSummarizedUpdates", ->
|
|
|
- beforeEach ->
|
|
|
- @before = Date.now()
|
|
|
- @min_count = 2
|
|
|
- @existingSummarizedUpdates = ["summarized-updates-3"]
|
|
|
- @summarizedUpdates = ["summarized-updates-3", "summarized-update-2", "summarized-update-1"]
|
|
|
-
|
|
|
- describe "when there are updates to get", ->
|
|
|
- beforeEach ->
|
|
|
- @updates = [
|
|
|
- {op: "mock-op-1", meta: end_ts: @before - 10},
|
|
|
- {op: "mock-op-1", meta: end_ts: @nextBeforeTimestamp = @before - 20}
|
|
|
- ]
|
|
|
- @existingSummarizedUpdates = ["summarized-updates-3"]
|
|
|
- @summarizedUpdates = ["summarized-updates-3", "summarized-update-2", "summarized-update-1"]
|
|
|
- @UpdatesManager._summarizeUpdates = sinon.stub().returns(@summarizedUpdates)
|
|
|
- @UpdatesManager.getProjectUpdatesWithUserInfo = sinon.stub().callsArgWith(2, null, @updates)
|
|
|
- @UpdatesManager._extendBatchOfSummarizedUpdates @project_id, @existingSummarizedUpdates, @before, @min_count, @callback
|
|
|
-
|
|
|
- it "should get the updates", ->
|
|
|
- @UpdatesManager.getProjectUpdatesWithUserInfo
|
|
|
- .calledWith(@project_id, { before: @before, limit: 3 * @min_count })
|
|
|
- .should.equal true
|
|
|
-
|
|
|
- it "should summarize the updates", ->
|
|
|
- @UpdatesManager._summarizeUpdates
|
|
|
- .calledWith(@updates, @existingSummarizedUpdates)
|
|
|
- .should.equal true
|
|
|
-
|
|
|
- it "should call the callback with the summarized updates and the next before timestamp", ->
|
|
|
- @callback.calledWith(null, @summarizedUpdates, @nextBeforeTimestamp).should.equal true
|
|
|
-
|
|
|
- describe "when there are no more updates", ->
|
|
|
- beforeEach ->
|
|
|
- @updates = []
|
|
|
- @UpdatesManager._summarizeUpdates = sinon.stub().returns(@summarizedUpdates)
|
|
|
- @UpdatesManager.getProjectUpdatesWithUserInfo = sinon.stub().callsArgWith(2, null, @updates)
|
|
|
- @UpdatesManager._extendBatchOfSummarizedUpdates @project_id, @existingSummarizedUpdates, @before, @min_count, @callback
|
|
|
-
|
|
|
- it "should call the callback with the summarized updates and null for nextBeforeTimestamp", ->
|
|
|
- @callback.calledWith(null, @summarizedUpdates, null).should.equal true
|
|
|
-
|
|
|
- describe "getSummarizedProjectUpdates", ->
|
|
|
- describe "when one batch of updates is enough to meet the limit", ->
|
|
|
- beforeEach ->
|
|
|
- @before = Date.now()
|
|
|
- @min_count = 2
|
|
|
- @updates = ["summarized-updates-3", "summarized-updates-2"]
|
|
|
- @nextBeforeTimestamp = @before - 100
|
|
|
- @UpdatesManager._extendBatchOfSummarizedUpdates = sinon.stub().callsArgWith(4, null, @updates, @nextBeforeTimestamp)
|
|
|
- @UpdatesManager.getSummarizedProjectUpdates @project_id, { before: @before, min_count: @min_count }, @callback
|
|
|
-
|
|
|
- it "should get the batch of summarized updates", ->
|
|
|
- @UpdatesManager._extendBatchOfSummarizedUpdates
|
|
|
- .calledWith(@project_id, [], @before, @min_count)
|
|
|
- .should.equal true
|
|
|
-
|
|
|
- it "should call the callback with the updates", ->
|
|
|
- @callback.calledWith(null, @updates, @nextBeforeTimestamp).should.equal true
|
|
|
-
|
|
|
- describe "when multiple batches are needed to meet the limit", ->
|
|
|
- beforeEach ->
|
|
|
- @before = Date.now()
|
|
|
- @min_count = 4
|
|
|
- @firstBatch = [{ toV: 6, fromV: 6 }, { toV: 5, fromV: 5 }]
|
|
|
- @nextBeforeTimestamp = @before - 100
|
|
|
- @secondBatch = [{ toV: 4, fromV: 4 }, { toV: 3, fromV: 3 }]
|
|
|
- @nextNextBeforeTimestamp = @before - 200
|
|
|
- @UpdatesManager._extendBatchOfSummarizedUpdates = (project_id, existingUpdates, before, desiredLength, callback) =>
|
|
|
- if existingUpdates.length == 0
|
|
|
- callback null, @firstBatch, @nextBeforeTimestamp
|
|
|
- else
|
|
|
- callback null, @firstBatch.concat(@secondBatch), @nextNextBeforeTimestamp
|
|
|
- sinon.spy @UpdatesManager, "_extendBatchOfSummarizedUpdates"
|
|
|
- @UpdatesManager.getSummarizedProjectUpdates @project_id, { before: @before, min_count: @min_count }, @callback
|
|
|
-
|
|
|
- it "should get the first batch of summarized updates", ->
|
|
|
- @UpdatesManager._extendBatchOfSummarizedUpdates
|
|
|
- .calledWith(@project_id, [], @before, @min_count)
|
|
|
- .should.equal true
|
|
|
-
|
|
|
- it "should get the second batch of summarized updates", ->
|
|
|
- @UpdatesManager._extendBatchOfSummarizedUpdates
|
|
|
- .calledWith(@project_id, @firstBatch, @nextBeforeTimestamp, @min_count)
|
|
|
- .should.equal true
|
|
|
-
|
|
|
- it "should call the callback with all the updates", ->
|
|
|
- @callback.calledWith(null, @firstBatch.concat(@secondBatch), @nextNextBeforeTimestamp).should.equal true
|
|
|
-
|
|
|
- describe "when the end of the database is hit", ->
|
|
|
- beforeEach ->
|
|
|
- @before = Date.now()
|
|
|
- @min_count = 4
|
|
|
- @updates = [{ toV: 6, fromV: 6 }, { toV: 5, fromV: 5 }]
|
|
|
- @UpdatesManager._extendBatchOfSummarizedUpdates = sinon.stub().callsArgWith(4, null, @updates, null)
|
|
|
- @UpdatesManager.getSummarizedProjectUpdates @project_id, { before: @before, min_count: @min_count }, @callback
|
|
|
-
|
|
|
- it "should get the batch of summarized updates", ->
|
|
|
- @UpdatesManager._extendBatchOfSummarizedUpdates
|
|
|
- .calledWith(@project_id, [], @before, @min_count)
|
|
|
- .should.equal true
|
|
|
-
|
|
|
- it "should call the callback with the updates", ->
|
|
|
- @callback.calledWith(null, @updates, null).should.equal true
|
|
|
-
|
|
|
- describe "fillUserInfo", ->
|
|
|
- describe "with valid users", ->
|
|
|
- beforeEach (done) ->
|
|
|
- {ObjectId} = require "mongojs"
|
|
|
- @user_id_1 = ObjectId().toString()
|
|
|
- @user_id_2 = ObjectId().toString()
|
|
|
- @updates = [{
|
|
|
- meta:
|
|
|
- user_id: @user_id_1
|
|
|
- op: "mock-op-1"
|
|
|
- }, {
|
|
|
- meta:
|
|
|
- user_id: @user_id_1
|
|
|
- op: "mock-op-2"
|
|
|
- }, {
|
|
|
- meta:
|
|
|
- user_id: @user_id_2
|
|
|
- op: "mock-op-3"
|
|
|
- }]
|
|
|
- @user_info = {}
|
|
|
- @user_info[@user_id_1] = email: "user1@sharelatex.com"
|
|
|
- @user_info[@user_id_2] = email: "user2@sharelatex.com"
|
|
|
+ # describe "getDocUpdates", ->
|
|
|
+ # beforeEach ->
|
|
|
+ # @updates = ["mock-updates"]
|
|
|
+ # @options = { to: "mock-to", limit: "mock-limit" }
|
|
|
+ # @MongoManager.getDocUpdates = sinon.stub().callsArgWith(2, null, @updates)
|
|
|
+ # @UpdatesManager.processUncompressedUpdatesWithLock = sinon.stub().callsArg(2)
|
|
|
+ # @UpdatesManager.getDocUpdates @project_id, @doc_id, @options, @callback
|
|
|
+
|
|
|
+ # it "should process outstanding updates", ->
|
|
|
+ # @UpdatesManager.processUncompressedUpdatesWithLock
|
|
|
+ # .calledWith(@project_id, @doc_id)
|
|
|
+ # .should.equal true
|
|
|
+
|
|
|
+ # it "should get the updates from the database", ->
|
|
|
+ # @MongoManager.getDocUpdates
|
|
|
+ # .calledWith(@doc_id, @options)
|
|
|
+ # .should.equal true
|
|
|
+
|
|
|
+ # it "should return the updates", ->
|
|
|
+ # @callback
|
|
|
+ # .calledWith(null, @updates)
|
|
|
+ # .should.equal true
|
|
|
+
|
|
|
+ # describe "getDocUpdatesWithUserInfo", ->
|
|
|
+ # beforeEach ->
|
|
|
+ # @updates = ["mock-updates"]
|
|
|
+ # @options = { to: "mock-to", limit: "mock-limit" }
|
|
|
+ # @updatesWithUserInfo = ["updates-with-user-info"]
|
|
|
+ # @UpdatesManager.getDocUpdates = sinon.stub().callsArgWith(3, null, @updates)
|
|
|
+ # @UpdatesManager.fillUserInfo = sinon.stub().callsArgWith(1, null, @updatesWithUserInfo)
|
|
|
+ # @UpdatesManager.getDocUpdatesWithUserInfo @project_id, @doc_id, @options, @callback
|
|
|
+
|
|
|
+ # it "should get the updates", ->
|
|
|
+ # @UpdatesManager.getDocUpdates
|
|
|
+ # .calledWith(@project_id, @doc_id, @options)
|
|
|
+ # .should.equal true
|
|
|
+
|
|
|
+ # it "should file the updates with the user info", ->
|
|
|
+ # @UpdatesManager.fillUserInfo
|
|
|
+ # .calledWith(@updates)
|
|
|
+ # .should.equal true
|
|
|
+
|
|
|
+ # it "should return the updates with the filled details", ->
|
|
|
+ # @callback.calledWith(null, @updatesWithUserInfo).should.equal true
|
|
|
+
|
|
|
+ # describe "getProjectUpdates", ->
|
|
|
+ # beforeEach ->
|
|
|
+ # @updates = ["mock-updates"]
|
|
|
+ # @options = { before: "mock-before", limit: "mock-limit" }
|
|
|
+ # @MongoManager.getProjectUpdates = sinon.stub().callsArgWith(2, null, @updates)
|
|
|
+ # @UpdatesManager.processUncompressedUpdatesForProject = sinon.stub().callsArg(1)
|
|
|
+ # @UpdatesManager.getProjectUpdates @project_id, @options, @callback
|
|
|
+
|
|
|
+ # it "should process any outstanding updates", ->
|
|
|
+ # @UpdatesManager.processUncompressedUpdatesForProject
|
|
|
+ # .calledWith(@project_id)
|
|
|
+ # .should.equal true
|
|
|
+
|
|
|
+ # it "should get the updates from the database", ->
|
|
|
+ # @MongoManager.getProjectUpdates
|
|
|
+ # .calledWith(@project_id, @options)
|
|
|
+ # .should.equal true
|
|
|
+
|
|
|
+ # it "should return the updates", ->
|
|
|
+ # @callback
|
|
|
+ # .calledWith(null, @updates)
|
|
|
+ # .should.equal true
|
|
|
+
|
|
|
+ # describe "processUncompressedUpdatesForProject", ->
|
|
|
+ # beforeEach (done) ->
|
|
|
+ # @doc_ids = ["mock-id-1", "mock-id-2"]
|
|
|
+ # @UpdatesManager.processUncompressedUpdatesWithLock = sinon.stub().callsArg(2)
|
|
|
+ # @RedisManager.getDocIdsWithHistoryOps = sinon.stub().callsArgWith(1, null, @doc_ids)
|
|
|
+ # @UpdatesManager.processUncompressedUpdatesForProject @project_id, () =>
|
|
|
+ # @callback()
|
|
|
+ # done()
|
|
|
+
|
|
|
+ # it "should get all the docs with history ops", ->
|
|
|
+ # @RedisManager.getDocIdsWithHistoryOps
|
|
|
+ # .calledWith(@project_id)
|
|
|
+ # .should.equal true
|
|
|
+
|
|
|
+ # it "should process the doc ops for the each doc_id", ->
|
|
|
+ # for doc_id in @doc_ids
|
|
|
+ # @UpdatesManager.processUncompressedUpdatesWithLock
|
|
|
+ # .calledWith(@project_id, doc_id)
|
|
|
+ # .should.equal true
|
|
|
+
|
|
|
+ # it "should call the callback", ->
|
|
|
+ # @callback.called.should.equal true
|
|
|
+
|
|
|
+ # describe "getProjectUpdatesWithUserInfo", ->
|
|
|
+ # beforeEach ->
|
|
|
+ # @updates = ["mock-updates"]
|
|
|
+ # @options = { before: "mock-before", limit: "mock-limit" }
|
|
|
+ # @updatesWithUserInfo = ["updates-with-user-info"]
|
|
|
+ # @UpdatesManager.getProjectUpdates = sinon.stub().callsArgWith(2, null, @updates)
|
|
|
+ # @UpdatesManager.fillUserInfo = sinon.stub().callsArgWith(1, null, @updatesWithUserInfo)
|
|
|
+ # @UpdatesManager.getProjectUpdatesWithUserInfo @project_id, @options, @callback
|
|
|
+
|
|
|
+ # it "should get the updates", ->
|
|
|
+ # @UpdatesManager.getProjectUpdates
|
|
|
+ # .calledWith(@project_id, @options)
|
|
|
+ # .should.equal true
|
|
|
+
|
|
|
+ # it "should file the updates with the user info", ->
|
|
|
+ # @UpdatesManager.fillUserInfo
|
|
|
+ # .calledWith(@updates)
|
|
|
+ # .should.equal true
|
|
|
+
|
|
|
+ # it "should return the updates with the filled details", ->
|
|
|
+ # @callback.calledWith(null, @updatesWithUserInfo).should.equal true
|
|
|
+
|
|
|
+ # describe "_extendBatchOfSummarizedUpdates", ->
|
|
|
+ # beforeEach ->
|
|
|
+ # @before = Date.now()
|
|
|
+ # @min_count = 2
|
|
|
+ # @existingSummarizedUpdates = ["summarized-updates-3"]
|
|
|
+ # @summarizedUpdates = ["summarized-updates-3", "summarized-update-2", "summarized-update-1"]
|
|
|
+
|
|
|
+ # describe "when there are updates to get", ->
|
|
|
+ # beforeEach ->
|
|
|
+ # @updates = [
|
|
|
+ # {op: "mock-op-1", meta: end_ts: @before - 10},
|
|
|
+ # {op: "mock-op-1", meta: end_ts: @nextBeforeTimestamp = @before - 20}
|
|
|
+ # ]
|
|
|
+ # @existingSummarizedUpdates = ["summarized-updates-3"]
|
|
|
+ # @summarizedUpdates = ["summarized-updates-3", "summarized-update-2", "summarized-update-1"]
|
|
|
+ # @UpdatesManager._summarizeUpdates = sinon.stub().returns(@summarizedUpdates)
|
|
|
+ # @UpdatesManager.getProjectUpdatesWithUserInfo = sinon.stub().callsArgWith(2, null, @updates)
|
|
|
+ # @UpdatesManager._extendBatchOfSummarizedUpdates @project_id, @existingSummarizedUpdates, @before, @min_count, @callback
|
|
|
+
|
|
|
+ # it "should get the updates", ->
|
|
|
+ # @UpdatesManager.getProjectUpdatesWithUserInfo
|
|
|
+ # .calledWith(@project_id, { before: @before, limit: 3 * @min_count })
|
|
|
+ # .should.equal true
|
|
|
+
|
|
|
+ # it "should summarize the updates", ->
|
|
|
+ # @UpdatesManager._summarizeUpdates
|
|
|
+ # .calledWith(@updates, @existingSummarizedUpdates)
|
|
|
+ # .should.equal true
|
|
|
+
|
|
|
+ # it "should call the callback with the summarized updates and the next before timestamp", ->
|
|
|
+ # @callback.calledWith(null, @summarizedUpdates, @nextBeforeTimestamp).should.equal true
|
|
|
+
|
|
|
+ # describe "when there are no more updates", ->
|
|
|
+ # beforeEach ->
|
|
|
+ # @updates = []
|
|
|
+ # @UpdatesManager._summarizeUpdates = sinon.stub().returns(@summarizedUpdates)
|
|
|
+ # @UpdatesManager.getProjectUpdatesWithUserInfo = sinon.stub().callsArgWith(2, null, @updates)
|
|
|
+ # @UpdatesManager._extendBatchOfSummarizedUpdates @project_id, @existingSummarizedUpdates, @before, @min_count, @callback
|
|
|
+
|
|
|
+ # it "should call the callback with the summarized updates and null for nextBeforeTimestamp", ->
|
|
|
+ # @callback.calledWith(null, @summarizedUpdates, null).should.equal true
|
|
|
+
|
|
|
+ # describe "getSummarizedProjectUpdates", ->
|
|
|
+ # describe "when one batch of updates is enough to meet the limit", ->
|
|
|
+ # beforeEach ->
|
|
|
+ # @before = Date.now()
|
|
|
+ # @min_count = 2
|
|
|
+ # @updates = ["summarized-updates-3", "summarized-updates-2"]
|
|
|
+ # @nextBeforeTimestamp = @before - 100
|
|
|
+ # @UpdatesManager._extendBatchOfSummarizedUpdates = sinon.stub().callsArgWith(4, null, @updates, @nextBeforeTimestamp)
|
|
|
+ # @UpdatesManager.getSummarizedProjectUpdates @project_id, { before: @before, min_count: @min_count }, @callback
|
|
|
+
|
|
|
+ # it "should get the batch of summarized updates", ->
|
|
|
+ # @UpdatesManager._extendBatchOfSummarizedUpdates
|
|
|
+ # .calledWith(@project_id, [], @before, @min_count)
|
|
|
+ # .should.equal true
|
|
|
+
|
|
|
+ # it "should call the callback with the updates", ->
|
|
|
+ # @callback.calledWith(null, @updates, @nextBeforeTimestamp).should.equal true
|
|
|
+
|
|
|
+ # describe "when multiple batches are needed to meet the limit", ->
|
|
|
+ # beforeEach ->
|
|
|
+ # @before = Date.now()
|
|
|
+ # @min_count = 4
|
|
|
+ # @firstBatch = [{ toV: 6, fromV: 6 }, { toV: 5, fromV: 5 }]
|
|
|
+ # @nextBeforeTimestamp = @before - 100
|
|
|
+ # @secondBatch = [{ toV: 4, fromV: 4 }, { toV: 3, fromV: 3 }]
|
|
|
+ # @nextNextBeforeTimestamp = @before - 200
|
|
|
+ # @UpdatesManager._extendBatchOfSummarizedUpdates = (project_id, existingUpdates, before, desiredLength, callback) =>
|
|
|
+ # if existingUpdates.length == 0
|
|
|
+ # callback null, @firstBatch, @nextBeforeTimestamp
|
|
|
+ # else
|
|
|
+ # callback null, @firstBatch.concat(@secondBatch), @nextNextBeforeTimestamp
|
|
|
+ # sinon.spy @UpdatesManager, "_extendBatchOfSummarizedUpdates"
|
|
|
+ # @UpdatesManager.getSummarizedProjectUpdates @project_id, { before: @before, min_count: @min_count }, @callback
|
|
|
+
|
|
|
+ # it "should get the first batch of summarized updates", ->
|
|
|
+ # @UpdatesManager._extendBatchOfSummarizedUpdates
|
|
|
+ # .calledWith(@project_id, [], @before, @min_count)
|
|
|
+ # .should.equal true
|
|
|
+
|
|
|
+ # it "should get the second batch of summarized updates", ->
|
|
|
+ # @UpdatesManager._extendBatchOfSummarizedUpdates
|
|
|
+ # .calledWith(@project_id, @firstBatch, @nextBeforeTimestamp, @min_count)
|
|
|
+ # .should.equal true
|
|
|
+
|
|
|
+ # it "should call the callback with all the updates", ->
|
|
|
+ # @callback.calledWith(null, @firstBatch.concat(@secondBatch), @nextNextBeforeTimestamp).should.equal true
|
|
|
+
|
|
|
+ # describe "when the end of the database is hit", ->
|
|
|
+ # beforeEach ->
|
|
|
+ # @before = Date.now()
|
|
|
+ # @min_count = 4
|
|
|
+ # @updates = [{ toV: 6, fromV: 6 }, { toV: 5, fromV: 5 }]
|
|
|
+ # @UpdatesManager._extendBatchOfSummarizedUpdates = sinon.stub().callsArgWith(4, null, @updates, null)
|
|
|
+ # @UpdatesManager.getSummarizedProjectUpdates @project_id, { before: @before, min_count: @min_count }, @callback
|
|
|
+
|
|
|
+ # it "should get the batch of summarized updates", ->
|
|
|
+ # @UpdatesManager._extendBatchOfSummarizedUpdates
|
|
|
+ # .calledWith(@project_id, [], @before, @min_count)
|
|
|
+ # .should.equal true
|
|
|
+
|
|
|
+ # it "should call the callback with the updates", ->
|
|
|
+ # @callback.calledWith(null, @updates, null).should.equal true
|
|
|
+
|
|
|
+ # describe "fillUserInfo", ->
|
|
|
+ # describe "with valid users", ->
|
|
|
+ # beforeEach (done) ->
|
|
|
+ # {ObjectId} = require "mongojs"
|
|
|
+ # @user_id_1 = ObjectId().toString()
|
|
|
+ # @user_id_2 = ObjectId().toString()
|
|
|
+ # @updates = [{
|
|
|
+ # meta:
|
|
|
+ # user_id: @user_id_1
|
|
|
+ # op: "mock-op-1"
|
|
|
+ # }, {
|
|
|
+ # meta:
|
|
|
+ # user_id: @user_id_1
|
|
|
+ # op: "mock-op-2"
|
|
|
+ # }, {
|
|
|
+ # meta:
|
|
|
+ # user_id: @user_id_2
|
|
|
+ # op: "mock-op-3"
|
|
|
+ # }]
|
|
|
+ # @user_info = {}
|
|
|
+ # @user_info[@user_id_1] = email: "user1@sharelatex.com"
|
|
|
+ # @user_info[@user_id_2] = email: "user2@sharelatex.com"
|
|
|
|
|
|
- @WebApiManager.getUserInfo = (user_id, callback = (error, userInfo) ->) =>
|
|
|
- callback null, @user_info[user_id]
|
|
|
- sinon.spy @WebApiManager, "getUserInfo"
|
|
|
-
|
|
|
- @UpdatesManager.fillUserInfo @updates, (error, @results) =>
|
|
|
- done()
|
|
|
-
|
|
|
- it "should only call getUserInfo once for each user_id", ->
|
|
|
- @WebApiManager.getUserInfo.calledTwice.should.equal true
|
|
|
- @WebApiManager.getUserInfo
|
|
|
- .calledWith(@user_id_1)
|
|
|
- .should.equal true
|
|
|
- @WebApiManager.getUserInfo
|
|
|
- .calledWith(@user_id_2)
|
|
|
- .should.equal true
|
|
|
-
|
|
|
- it "should return the updates with the user info filled", ->
|
|
|
- expect(@results).to.deep.equal [{
|
|
|
- meta:
|
|
|
- user:
|
|
|
- email: "user1@sharelatex.com"
|
|
|
- op: "mock-op-1"
|
|
|
- }, {
|
|
|
- meta:
|
|
|
- user:
|
|
|
- email: "user1@sharelatex.com"
|
|
|
- op: "mock-op-2"
|
|
|
- }, {
|
|
|
- meta:
|
|
|
- user:
|
|
|
- email: "user2@sharelatex.com"
|
|
|
- op: "mock-op-3"
|
|
|
- }]
|
|
|
-
|
|
|
-
|
|
|
- describe "with invalid user ids", ->
|
|
|
- beforeEach (done) ->
|
|
|
- @updates = [{
|
|
|
- meta:
|
|
|
- user_id: null
|
|
|
- op: "mock-op-1"
|
|
|
- }, {
|
|
|
- meta:
|
|
|
- user_id: "anonymous-user"
|
|
|
- op: "mock-op-2"
|
|
|
- }]
|
|
|
- @WebApiManager.getUserInfo = (user_id, callback = (error, userInfo) ->) =>
|
|
|
- callback null, @user_info[user_id]
|
|
|
- sinon.spy @WebApiManager, "getUserInfo"
|
|
|
-
|
|
|
- @UpdatesManager.fillUserInfo @updates, (error, @results) =>
|
|
|
- done()
|
|
|
-
|
|
|
- it "should not call getUserInfo", ->
|
|
|
- @WebApiManager.getUserInfo.called.should.equal false
|
|
|
-
|
|
|
- it "should return the updates without the user info filled", ->
|
|
|
- expect(@results).to.deep.equal [{
|
|
|
- meta: {}
|
|
|
- op: "mock-op-1"
|
|
|
- }, {
|
|
|
- meta: {}
|
|
|
- op: "mock-op-2"
|
|
|
- }]
|
|
|
-
|
|
|
- describe "_summarizeUpdates", ->
|
|
|
- beforeEach ->
|
|
|
- @now = Date.now()
|
|
|
- @user_1 = { id: "mock-user-1" }
|
|
|
- @user_2 = { id: "mock-user-2" }
|
|
|
-
|
|
|
- it "should concat updates that are close in time", ->
|
|
|
- result = @UpdatesManager._summarizeUpdates [{
|
|
|
- doc_id: "doc-id-1"
|
|
|
- meta:
|
|
|
- user: @user_1
|
|
|
- start_ts: @now + 20
|
|
|
- end_ts: @now + 30
|
|
|
- v: 5
|
|
|
- }, {
|
|
|
- doc_id: "doc-id-1"
|
|
|
- meta:
|
|
|
- user: @user_2
|
|
|
- start_ts: @now
|
|
|
- end_ts: @now + 10
|
|
|
- v: 4
|
|
|
- }]
|
|
|
-
|
|
|
- expect(result).to.deep.equal [{
|
|
|
- docs:
|
|
|
- "doc-id-1":
|
|
|
- fromV: 4
|
|
|
- toV: 5
|
|
|
- meta:
|
|
|
- users: [@user_1, @user_2]
|
|
|
- start_ts: @now
|
|
|
- end_ts: @now + 30
|
|
|
- }]
|
|
|
-
|
|
|
- it "should leave updates that are far apart in time", ->
|
|
|
- oneDay = 1000 * 60 * 60 * 24
|
|
|
- result = @UpdatesManager._summarizeUpdates [{
|
|
|
- doc_id: "doc-id-1"
|
|
|
- meta:
|
|
|
- user: @user_2
|
|
|
- start_ts: @now + oneDay
|
|
|
- end_ts: @now + oneDay + 10
|
|
|
- v: 5
|
|
|
- }, {
|
|
|
- doc_id: "doc-id-1"
|
|
|
- meta:
|
|
|
- user: @user_1
|
|
|
- start_ts: @now
|
|
|
- end_ts: @now + 10
|
|
|
- v: 4
|
|
|
- }]
|
|
|
- expect(result).to.deep.equal [{
|
|
|
- docs:
|
|
|
- "doc-id-1":
|
|
|
- fromV: 5
|
|
|
- toV: 5
|
|
|
- meta:
|
|
|
- users: [@user_2]
|
|
|
- start_ts: @now + oneDay
|
|
|
- end_ts: @now + oneDay + 10
|
|
|
- }, {
|
|
|
- docs:
|
|
|
- "doc-id-1":
|
|
|
- fromV: 4
|
|
|
- toV: 4
|
|
|
- meta:
|
|
|
- users: [@user_1]
|
|
|
- start_ts: @now
|
|
|
- end_ts: @now + 10
|
|
|
- }]
|
|
|
-
|
|
|
- it "should concat onto existing summarized updates", ->
|
|
|
- result = @UpdatesManager._summarizeUpdates [{
|
|
|
- doc_id: "doc-id-2"
|
|
|
- meta:
|
|
|
- user: @user_1
|
|
|
- start_ts: @now + 20
|
|
|
- end_ts: @now + 30
|
|
|
- v: 5
|
|
|
- }, {
|
|
|
- doc_id: "doc-id-2"
|
|
|
- meta:
|
|
|
- user: @user_2
|
|
|
- start_ts: @now
|
|
|
- end_ts: @now + 10
|
|
|
- v: 4
|
|
|
- }], [{
|
|
|
- docs:
|
|
|
- "doc-id-1":
|
|
|
- fromV: 6
|
|
|
- toV: 8
|
|
|
- meta:
|
|
|
- users: [@user_1]
|
|
|
- start_ts: @now + 40
|
|
|
- end_ts: @now + 50
|
|
|
- }]
|
|
|
- expect(result).to.deep.equal [{
|
|
|
- docs:
|
|
|
- "doc-id-1":
|
|
|
- toV: 8
|
|
|
- fromV: 6
|
|
|
- "doc-id-2":
|
|
|
- toV: 5
|
|
|
- fromV: 4
|
|
|
- meta:
|
|
|
- users: [@user_1, @user_2]
|
|
|
- start_ts: @now
|
|
|
- end_ts: @now + 50
|
|
|
- }]
|
|
|
-
|
|
|
- it "should include null user values", ->
|
|
|
- result = @UpdatesManager._summarizeUpdates [{
|
|
|
- doc_id: "doc-id-1"
|
|
|
- meta:
|
|
|
- user: @user_1
|
|
|
- start_ts: @now + 20
|
|
|
- end_ts: @now + 30
|
|
|
- v: 5
|
|
|
- }, {
|
|
|
- doc_id: "doc-id-1"
|
|
|
- meta:
|
|
|
- user: null
|
|
|
- start_ts: @now
|
|
|
- end_ts: @now + 10
|
|
|
- v: 4
|
|
|
- }]
|
|
|
- expect(result).to.deep.equal [{
|
|
|
- docs:
|
|
|
- "doc-id-1":
|
|
|
- fromV: 4
|
|
|
- toV: 5
|
|
|
- meta:
|
|
|
- users: [@user_1, null]
|
|
|
- start_ts: @now
|
|
|
- end_ts: @now + 30
|
|
|
- }]
|
|
|
-
|
|
|
- it "should include null user values, when the null is earlier in the updates list", ->
|
|
|
- result = @UpdatesManager._summarizeUpdates [{
|
|
|
- doc_id: "doc-id-1"
|
|
|
- meta:
|
|
|
- user: null
|
|
|
- start_ts: @now
|
|
|
- end_ts: @now + 10
|
|
|
- v: 4
|
|
|
- }, {
|
|
|
- doc_id: "doc-id-1"
|
|
|
- meta:
|
|
|
- user: @user_1
|
|
|
- start_ts: @now + 20
|
|
|
- end_ts: @now + 30
|
|
|
- v: 5
|
|
|
- }]
|
|
|
- expect(result).to.deep.equal [{
|
|
|
- docs:
|
|
|
- "doc-id-1":
|
|
|
- fromV: 4
|
|
|
- toV: 5
|
|
|
- meta:
|
|
|
- users: [null, @user_1]
|
|
|
- start_ts: @now
|
|
|
- end_ts: @now + 30
|
|
|
- }]
|
|
|
-
|
|
|
- it "should roll several null user values into one", ->
|
|
|
- result = @UpdatesManager._summarizeUpdates [{
|
|
|
- doc_id: "doc-id-1"
|
|
|
- meta:
|
|
|
- user: @user_1
|
|
|
- start_ts: @now + 20
|
|
|
- end_ts: @now + 30
|
|
|
- v: 5
|
|
|
- }, {
|
|
|
- doc_id: "doc-id-1"
|
|
|
- meta:
|
|
|
- user: null
|
|
|
- start_ts: @now
|
|
|
- end_ts: @now + 10
|
|
|
- v: 4
|
|
|
- }, {
|
|
|
- doc_id: "doc-id-1"
|
|
|
- meta:
|
|
|
- user: null
|
|
|
- start_ts: @now + 2
|
|
|
- end_ts: @now + 4
|
|
|
- v: 4
|
|
|
- }]
|
|
|
- expect(result).to.deep.equal [{
|
|
|
- docs:
|
|
|
- "doc-id-1":
|
|
|
- fromV: 4
|
|
|
- toV: 5
|
|
|
- meta:
|
|
|
- users: [@user_1, null]
|
|
|
- start_ts: @now
|
|
|
- end_ts: @now + 30
|
|
|
- }]
|
|
|
+ # @WebApiManager.getUserInfo = (user_id, callback = (error, userInfo) ->) =>
|
|
|
+ # callback null, @user_info[user_id]
|
|
|
+ # sinon.spy @WebApiManager, "getUserInfo"
|
|
|
+
|
|
|
+ # @UpdatesManager.fillUserInfo @updates, (error, @results) =>
|
|
|
+ # done()
|
|
|
+
|
|
|
+ # it "should only call getUserInfo once for each user_id", ->
|
|
|
+ # @WebApiManager.getUserInfo.calledTwice.should.equal true
|
|
|
+ # @WebApiManager.getUserInfo
|
|
|
+ # .calledWith(@user_id_1)
|
|
|
+ # .should.equal true
|
|
|
+ # @WebApiManager.getUserInfo
|
|
|
+ # .calledWith(@user_id_2)
|
|
|
+ # .should.equal true
|
|
|
+
|
|
|
+ # it "should return the updates with the user info filled", ->
|
|
|
+ # expect(@results).to.deep.equal [{
|
|
|
+ # meta:
|
|
|
+ # user:
|
|
|
+ # email: "user1@sharelatex.com"
|
|
|
+ # op: "mock-op-1"
|
|
|
+ # }, {
|
|
|
+ # meta:
|
|
|
+ # user:
|
|
|
+ # email: "user1@sharelatex.com"
|
|
|
+ # op: "mock-op-2"
|
|
|
+ # }, {
|
|
|
+ # meta:
|
|
|
+ # user:
|
|
|
+ # email: "user2@sharelatex.com"
|
|
|
+ # op: "mock-op-3"
|
|
|
+ # }]
|
|
|
+
|
|
|
+
|
|
|
+ # describe "with invalid user ids", ->
|
|
|
+ # beforeEach (done) ->
|
|
|
+ # @updates = [{
|
|
|
+ # meta:
|
|
|
+ # user_id: null
|
|
|
+ # op: "mock-op-1"
|
|
|
+ # }, {
|
|
|
+ # meta:
|
|
|
+ # user_id: "anonymous-user"
|
|
|
+ # op: "mock-op-2"
|
|
|
+ # }]
|
|
|
+ # @WebApiManager.getUserInfo = (user_id, callback = (error, userInfo) ->) =>
|
|
|
+ # callback null, @user_info[user_id]
|
|
|
+ # sinon.spy @WebApiManager, "getUserInfo"
|
|
|
+
|
|
|
+ # @UpdatesManager.fillUserInfo @updates, (error, @results) =>
|
|
|
+ # done()
|
|
|
+
|
|
|
+ # it "should not call getUserInfo", ->
|
|
|
+ # @WebApiManager.getUserInfo.called.should.equal false
|
|
|
+
|
|
|
+ # it "should return the updates without the user info filled", ->
|
|
|
+ # expect(@results).to.deep.equal [{
|
|
|
+ # meta: {}
|
|
|
+ # op: "mock-op-1"
|
|
|
+ # }, {
|
|
|
+ # meta: {}
|
|
|
+ # op: "mock-op-2"
|
|
|
+ # }]
|
|
|
+
|
|
|
+ # describe "_summarizeUpdates", ->
|
|
|
+ # beforeEach ->
|
|
|
+ # @now = Date.now()
|
|
|
+ # @user_1 = { id: "mock-user-1" }
|
|
|
+ # @user_2 = { id: "mock-user-2" }
|
|
|
+
|
|
|
+ # it "should concat updates that are close in time", ->
|
|
|
+ # result = @UpdatesManager._summarizeUpdates [{
|
|
|
+ # doc_id: "doc-id-1"
|
|
|
+ # meta:
|
|
|
+ # user: @user_1
|
|
|
+ # start_ts: @now + 20
|
|
|
+ # end_ts: @now + 30
|
|
|
+ # v: 5
|
|
|
+ # }, {
|
|
|
+ # doc_id: "doc-id-1"
|
|
|
+ # meta:
|
|
|
+ # user: @user_2
|
|
|
+ # start_ts: @now
|
|
|
+ # end_ts: @now + 10
|
|
|
+ # v: 4
|
|
|
+ # }]
|
|
|
+
|
|
|
+ # expect(result).to.deep.equal [{
|
|
|
+ # docs:
|
|
|
+ # "doc-id-1":
|
|
|
+ # fromV: 4
|
|
|
+ # toV: 5
|
|
|
+ # meta:
|
|
|
+ # users: [@user_1, @user_2]
|
|
|
+ # start_ts: @now
|
|
|
+ # end_ts: @now + 30
|
|
|
+ # }]
|
|
|
+
|
|
|
+ # it "should leave updates that are far apart in time", ->
|
|
|
+ # oneDay = 1000 * 60 * 60 * 24
|
|
|
+ # result = @UpdatesManager._summarizeUpdates [{
|
|
|
+ # doc_id: "doc-id-1"
|
|
|
+ # meta:
|
|
|
+ # user: @user_2
|
|
|
+ # start_ts: @now + oneDay
|
|
|
+ # end_ts: @now + oneDay + 10
|
|
|
+ # v: 5
|
|
|
+ # }, {
|
|
|
+ # doc_id: "doc-id-1"
|
|
|
+ # meta:
|
|
|
+ # user: @user_1
|
|
|
+ # start_ts: @now
|
|
|
+ # end_ts: @now + 10
|
|
|
+ # v: 4
|
|
|
+ # }]
|
|
|
+ # expect(result).to.deep.equal [{
|
|
|
+ # docs:
|
|
|
+ # "doc-id-1":
|
|
|
+ # fromV: 5
|
|
|
+ # toV: 5
|
|
|
+ # meta:
|
|
|
+ # users: [@user_2]
|
|
|
+ # start_ts: @now + oneDay
|
|
|
+ # end_ts: @now + oneDay + 10
|
|
|
+ # }, {
|
|
|
+ # docs:
|
|
|
+ # "doc-id-1":
|
|
|
+ # fromV: 4
|
|
|
+ # toV: 4
|
|
|
+ # meta:
|
|
|
+ # users: [@user_1]
|
|
|
+ # start_ts: @now
|
|
|
+ # end_ts: @now + 10
|
|
|
+ # }]
|
|
|
+
|
|
|
+ # it "should concat onto existing summarized updates", ->
|
|
|
+ # result = @UpdatesManager._summarizeUpdates [{
|
|
|
+ # doc_id: "doc-id-2"
|
|
|
+ # meta:
|
|
|
+ # user: @user_1
|
|
|
+ # start_ts: @now + 20
|
|
|
+ # end_ts: @now + 30
|
|
|
+ # v: 5
|
|
|
+ # }, {
|
|
|
+ # doc_id: "doc-id-2"
|
|
|
+ # meta:
|
|
|
+ # user: @user_2
|
|
|
+ # start_ts: @now
|
|
|
+ # end_ts: @now + 10
|
|
|
+ # v: 4
|
|
|
+ # }], [{
|
|
|
+ # docs:
|
|
|
+ # "doc-id-1":
|
|
|
+ # fromV: 6
|
|
|
+ # toV: 8
|
|
|
+ # meta:
|
|
|
+ # users: [@user_1]
|
|
|
+ # start_ts: @now + 40
|
|
|
+ # end_ts: @now + 50
|
|
|
+ # }]
|
|
|
+ # expect(result).to.deep.equal [{
|
|
|
+ # docs:
|
|
|
+ # "doc-id-1":
|
|
|
+ # toV: 8
|
|
|
+ # fromV: 6
|
|
|
+ # "doc-id-2":
|
|
|
+ # toV: 5
|
|
|
+ # fromV: 4
|
|
|
+ # meta:
|
|
|
+ # users: [@user_1, @user_2]
|
|
|
+ # start_ts: @now
|
|
|
+ # end_ts: @now + 50
|
|
|
+ # }]
|
|
|
+
|
|
|
+ # it "should include null user values", ->
|
|
|
+ # result = @UpdatesManager._summarizeUpdates [{
|
|
|
+ # doc_id: "doc-id-1"
|
|
|
+ # meta:
|
|
|
+ # user: @user_1
|
|
|
+ # start_ts: @now + 20
|
|
|
+ # end_ts: @now + 30
|
|
|
+ # v: 5
|
|
|
+ # }, {
|
|
|
+ # doc_id: "doc-id-1"
|
|
|
+ # meta:
|
|
|
+ # user: null
|
|
|
+ # start_ts: @now
|
|
|
+ # end_ts: @now + 10
|
|
|
+ # v: 4
|
|
|
+ # }]
|
|
|
+ # expect(result).to.deep.equal [{
|
|
|
+ # docs:
|
|
|
+ # "doc-id-1":
|
|
|
+ # fromV: 4
|
|
|
+ # toV: 5
|
|
|
+ # meta:
|
|
|
+ # users: [@user_1, null]
|
|
|
+ # start_ts: @now
|
|
|
+ # end_ts: @now + 30
|
|
|
+ # }]
|
|
|
+
|
|
|
+ # it "should include null user values, when the null is earlier in the updates list", ->
|
|
|
+ # result = @UpdatesManager._summarizeUpdates [{
|
|
|
+ # doc_id: "doc-id-1"
|
|
|
+ # meta:
|
|
|
+ # user: null
|
|
|
+ # start_ts: @now
|
|
|
+ # end_ts: @now + 10
|
|
|
+ # v: 4
|
|
|
+ # }, {
|
|
|
+ # doc_id: "doc-id-1"
|
|
|
+ # meta:
|
|
|
+ # user: @user_1
|
|
|
+ # start_ts: @now + 20
|
|
|
+ # end_ts: @now + 30
|
|
|
+ # v: 5
|
|
|
+ # }]
|
|
|
+ # expect(result).to.deep.equal [{
|
|
|
+ # docs:
|
|
|
+ # "doc-id-1":
|
|
|
+ # fromV: 4
|
|
|
+ # toV: 5
|
|
|
+ # meta:
|
|
|
+ # users: [null, @user_1]
|
|
|
+ # start_ts: @now
|
|
|
+ # end_ts: @now + 30
|
|
|
+ # }]
|
|
|
+
|
|
|
+ # it "should roll several null user values into one", ->
|
|
|
+ # result = @UpdatesManager._summarizeUpdates [{
|
|
|
+ # doc_id: "doc-id-1"
|
|
|
+ # meta:
|
|
|
+ # user: @user_1
|
|
|
+ # start_ts: @now + 20
|
|
|
+ # end_ts: @now + 30
|
|
|
+ # v: 5
|
|
|
+ # }, {
|
|
|
+ # doc_id: "doc-id-1"
|
|
|
+ # meta:
|
|
|
+ # user: null
|
|
|
+ # start_ts: @now
|
|
|
+ # end_ts: @now + 10
|
|
|
+ # v: 4
|
|
|
+ # }, {
|
|
|
+ # doc_id: "doc-id-1"
|
|
|
+ # meta:
|
|
|
+ # user: null
|
|
|
+ # start_ts: @now + 2
|
|
|
+ # end_ts: @now + 4
|
|
|
+ # v: 4
|
|
|
+ # }]
|
|
|
+ # expect(result).to.deep.equal [{
|
|
|
+ # docs:
|
|
|
+ # "doc-id-1":
|
|
|
+ # fromV: 4
|
|
|
+ # toV: 5
|
|
|
+ # meta:
|
|
|
+ # users: [@user_1, null]
|
|
|
+ # start_ts: @now
|
|
|
+ # end_ts: @now + 30
|
|
|
+ # }]
|