|
@@ -70,6 +70,7 @@ describe "EditorController", ->
|
|
|
'../ThirdPartyDataStore/TpdsPollingBackgroundTasks':@TpdsPollingBackgroundTasks
|
|
'../ThirdPartyDataStore/TpdsPollingBackgroundTasks':@TpdsPollingBackgroundTasks
|
|
|
'./EditorRealTimeController':@EditorRealTimeController = {}
|
|
'./EditorRealTimeController':@EditorRealTimeController = {}
|
|
|
"../../infrastructure/Metrics": @Metrics = { inc: sinon.stub() }
|
|
"../../infrastructure/Metrics": @Metrics = { inc: sinon.stub() }
|
|
|
|
|
+ "../TrackChanges/TrackChangesManager": @TrackChangesManager = {}
|
|
|
'redis':createClient:-> auth:->
|
|
'redis':createClient:-> auth:->
|
|
|
"logger-sharelatex": @logger =
|
|
"logger-sharelatex": @logger =
|
|
|
log: sinon.stub()
|
|
log: sinon.stub()
|
|
@@ -219,20 +220,24 @@ describe "EditorController", ->
|
|
|
.should.equal true
|
|
.should.equal true
|
|
|
|
|
|
|
|
describe "flushProjectIfEmpty", ->
|
|
describe "flushProjectIfEmpty", ->
|
|
|
|
|
+ beforeEach ->
|
|
|
|
|
+ @DocumentUpdaterHandler.flushProjectToMongoAndDelete = sinon.stub()
|
|
|
|
|
+ @TrackChangesManager.flushProject = sinon.stub()
|
|
|
|
|
+
|
|
|
describe "when a project has no more users", ->
|
|
describe "when a project has no more users", ->
|
|
|
it "should do the flush after the config set timeout to ensure that a reconect didn't just happen", (done)->
|
|
it "should do the flush after the config set timeout to ensure that a reconect didn't just happen", (done)->
|
|
|
@rooms[@project_id] = []
|
|
@rooms[@project_id] = []
|
|
|
- @DocumentUpdaterHandler.flushProjectToMongoAndDelete = sinon.stub()
|
|
|
|
|
@EditorController.flushProjectIfEmpty @project_id, =>
|
|
@EditorController.flushProjectIfEmpty @project_id, =>
|
|
|
@DocumentUpdaterHandler.flushProjectToMongoAndDelete.calledWith(@project_id).should.equal(true)
|
|
@DocumentUpdaterHandler.flushProjectToMongoAndDelete.calledWith(@project_id).should.equal(true)
|
|
|
|
|
+ @TrackChangesManager.flushProject.calledWith(@project_id).should.equal true
|
|
|
done()
|
|
done()
|
|
|
|
|
|
|
|
describe "when a project still has connected users", ->
|
|
describe "when a project still has connected users", ->
|
|
|
it "should not flush the project", (done)->
|
|
it "should not flush the project", (done)->
|
|
|
@rooms[@project_id] = ["socket-id-1", "socket-id-2"]
|
|
@rooms[@project_id] = ["socket-id-1", "socket-id-2"]
|
|
|
- @DocumentUpdaterHandler.flushProjectToMongoAndDelete = sinon.stub()
|
|
|
|
|
@EditorController.flushProjectIfEmpty @project_id, =>
|
|
@EditorController.flushProjectIfEmpty @project_id, =>
|
|
|
@DocumentUpdaterHandler.flushProjectToMongoAndDelete.calledWith(@project_id).should.equal(false)
|
|
@DocumentUpdaterHandler.flushProjectToMongoAndDelete.calledWith(@project_id).should.equal(false)
|
|
|
|
|
+ @TrackChangesManager.flushProject.calledWith(@project_id).should.equal false
|
|
|
done()
|
|
done()
|
|
|
|
|
|
|
|
describe "updateClientPosition", ->
|
|
describe "updateClientPosition", ->
|