mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-27 02:51:57 +02:00
Don't flush to track changes now that this happens in doc updater
This commit is contained in:
@@ -1,16 +0,0 @@
|
||||
settings = require "settings-sharelatex"
|
||||
request = require "request"
|
||||
logger = require "logger-sharelatex"
|
||||
|
||||
module.exports = TrackChangesManager =
|
||||
flushProject: (project_id, callback = (error) ->) ->
|
||||
logger.log project_id: project_id, "flushing project in track-changes api"
|
||||
url = "#{settings.apis.trackchanges.url}/project/#{project_id}/flush"
|
||||
request.post url, (error, res, body) ->
|
||||
return callback(error) if error?
|
||||
if 200 <= res.statusCode < 300
|
||||
callback(null)
|
||||
else
|
||||
error = new Error("track-changes api responded with non-success code: #{res.statusCode}")
|
||||
logger.error err: error, project_id: project_id, "error flushing project in track-changes api"
|
||||
callback(error)
|
||||
@@ -4,7 +4,6 @@ WebApiManager = require "./WebApiManager"
|
||||
AuthorizationManager = require "./AuthorizationManager"
|
||||
DocumentUpdaterManager = require "./DocumentUpdaterManager"
|
||||
ConnectedUsersManager = require "./ConnectedUsersManager"
|
||||
TrackChangesManager = require "./TrackChangesManager"
|
||||
WebsocketLoadBalancer = require "./WebsocketLoadBalancer"
|
||||
Utils = require "./Utils"
|
||||
|
||||
@@ -68,9 +67,6 @@ module.exports = WebsocketController =
|
||||
DocumentUpdaterManager.flushProjectToMongoAndDelete project_id, (err) ->
|
||||
if err?
|
||||
logger.error {err, project_id, user_id, client_id: client.id}, "error flushing to doc updater after leaving project"
|
||||
TrackChangesManager.flushProject project_id, (err) ->
|
||||
if err?
|
||||
logger.error {err, project_id, user_id, client_id: client.id}, "error flushing to track changes after leaving project"
|
||||
callback()
|
||||
, WebsocketController.FLUSH_IF_EMPTY_DELAY
|
||||
|
||||
|
||||
@@ -19,8 +19,6 @@ module.exports =
|
||||
pass: "password"
|
||||
documentupdater:
|
||||
url: "http://localhost:3003"
|
||||
trackchanges:
|
||||
url: "http://localhost:3015"
|
||||
|
||||
security:
|
||||
sessionSecret: "secret-please-change"
|
||||
|
||||
@@ -1,15 +1,12 @@
|
||||
RealTimeClient = require "./helpers/RealTimeClient"
|
||||
MockDocUpdaterServer = require "./helpers/MockDocUpdaterServer"
|
||||
MockTrackChangesServer = require "./helpers/MockTrackChangesServer"
|
||||
FixturesManager = require "./helpers/FixturesManager"
|
||||
|
||||
async = require "async"
|
||||
|
||||
describe "leaveProject", ->
|
||||
before (done) ->
|
||||
MockDocUpdaterServer.run (error) ->
|
||||
return done(error) if error?
|
||||
MockTrackChangesServer.run done
|
||||
MockDocUpdaterServer.run done
|
||||
|
||||
describe "with other clients in the project", ->
|
||||
before (done) ->
|
||||
@@ -67,11 +64,6 @@ describe "leaveProject", ->
|
||||
MockDocUpdaterServer.deleteProject
|
||||
.calledWith(@project_id)
|
||||
.should.equal false
|
||||
|
||||
it "should not flush the project in track changes", ->
|
||||
MockTrackChangesServer.flushProject
|
||||
.calledWith(@project_id)
|
||||
.should.equal false
|
||||
|
||||
describe "with no other clients in the project", ->
|
||||
before (done) ->
|
||||
@@ -106,9 +98,3 @@ describe "leaveProject", ->
|
||||
MockDocUpdaterServer.deleteProject
|
||||
.calledWith(@project_id)
|
||||
.should.equal true
|
||||
|
||||
it "should flush the project in track changes", ->
|
||||
MockTrackChangesServer.flushProject
|
||||
.calledWith(@project_id)
|
||||
.should.equal true
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
sinon = require "sinon"
|
||||
express = require "express"
|
||||
|
||||
module.exports = MockTrackChangesServer =
|
||||
flushProject: sinon.stub().callsArg(1)
|
||||
|
||||
flushProjectRequest: (req, res, next) ->
|
||||
{project_id} = req.params
|
||||
MockTrackChangesServer.flushProject project_id, (error) ->
|
||||
return next(error) if error?
|
||||
res.sendStatus 204
|
||||
|
||||
running: false
|
||||
run: (callback = (error) ->) ->
|
||||
if MockTrackChangesServer.running
|
||||
return callback()
|
||||
app = express()
|
||||
app.post "/project/:project_id/flush", MockTrackChangesServer.flushProjectRequest
|
||||
app.listen 3015, (error) ->
|
||||
MockTrackChangesServer.running = true
|
||||
callback(error)
|
||||
@@ -1,48 +0,0 @@
|
||||
chai = require('chai')
|
||||
chai.should()
|
||||
sinon = require("sinon")
|
||||
modulePath = "../../../app/js/TrackChangesManager"
|
||||
SandboxedModule = require('sandboxed-module')
|
||||
|
||||
describe "TrackChangesManager", ->
|
||||
beforeEach ->
|
||||
@TrackChangesManager = SandboxedModule.require modulePath, requires:
|
||||
"request" : @request = sinon.stub()
|
||||
"settings-sharelatex": @settings =
|
||||
apis:
|
||||
trackchanges:
|
||||
url: "trackchanges.sharelatex.com"
|
||||
"logger-sharelatex": @logger = {log: sinon.stub(), error: sinon.stub()}
|
||||
@project_id = "project-id-123"
|
||||
@callback = sinon.stub()
|
||||
|
||||
describe "flushProject", ->
|
||||
describe "with a successful response code", ->
|
||||
beforeEach ->
|
||||
@request.post = sinon.stub().callsArgWith(1, null, statusCode: 204, "")
|
||||
@TrackChangesManager.flushProject @project_id, @callback
|
||||
|
||||
it "should flush the project in the track changes api", ->
|
||||
@request.post
|
||||
.calledWith("#{@settings.apis.trackchanges.url}/project/#{@project_id}/flush")
|
||||
.should.equal true
|
||||
|
||||
it "should call the callback without an error", ->
|
||||
@callback.calledWith(null).should.equal true
|
||||
|
||||
describe "with a failed response code", ->
|
||||
beforeEach ->
|
||||
@request.post = sinon.stub().callsArgWith(1, null, statusCode: 500, "")
|
||||
@TrackChangesManager.flushProject @project_id, @callback
|
||||
|
||||
it "should call the callback with an error", ->
|
||||
@callback.calledWith(new Error("track-changes api responded with a non-success code: 500")).should.equal true
|
||||
|
||||
it "should log the error", ->
|
||||
@logger.error
|
||||
.calledWith({
|
||||
err: new Error("track-changes api responded with a non-success code: 500")
|
||||
project_id: @project_id
|
||||
}, "error flushing project in track-changes api")
|
||||
.should.equal true
|
||||
|
||||
@@ -29,7 +29,6 @@ describe 'WebsocketController', ->
|
||||
"./WebApiManager": @WebApiManager = {}
|
||||
"./AuthorizationManager": @AuthorizationManager = {}
|
||||
"./DocumentUpdaterManager": @DocumentUpdaterManager = {}
|
||||
"./TrackChangesManager": @TrackChangesManager = {}
|
||||
"./ConnectedUsersManager": @ConnectedUsersManager = {}
|
||||
"./WebsocketLoadBalancer": @WebsocketLoadBalancer = {}
|
||||
"logger-sharelatex": @logger = { log: sinon.stub(), error: sinon.stub() }
|
||||
@@ -120,7 +119,6 @@ describe 'WebsocketController', ->
|
||||
describe "leaveProject", ->
|
||||
beforeEach ->
|
||||
@DocumentUpdaterManager.flushProjectToMongoAndDelete = sinon.stub().callsArg(1)
|
||||
@TrackChangesManager.flushProject = sinon.stub().callsArg(1)
|
||||
@ConnectedUsersManager.markUserAsDisconnected = sinon.stub().callsArg(2)
|
||||
@WebsocketLoadBalancer.emitToRoom = sinon.stub()
|
||||
@clientsInRoom = []
|
||||
@@ -154,11 +152,6 @@ describe 'WebsocketController', ->
|
||||
.calledWith(@project_id)
|
||||
.should.equal true
|
||||
|
||||
it "should flush the changes in the track changes api", ->
|
||||
@TrackChangesManager.flushProject
|
||||
.calledWith(@project_id)
|
||||
.should.equal true
|
||||
|
||||
it "should increment the leave-project metric", ->
|
||||
@metrics.inc.calledWith("editor.leave-project").should.equal true
|
||||
|
||||
@@ -170,10 +163,6 @@ describe 'WebsocketController', ->
|
||||
it "should not flush the project in the document updater", ->
|
||||
@DocumentUpdaterManager.flushProjectToMongoAndDelete
|
||||
.called.should.equal false
|
||||
|
||||
it "should not flush the changes in the track changes api", ->
|
||||
@TrackChangesManager.flushProject
|
||||
.called.should.equal false
|
||||
|
||||
describe "joinDoc", ->
|
||||
beforeEach ->
|
||||
|
||||
Reference in New Issue
Block a user