remove unused HistoryManager

This commit is contained in:
Hayden Faulds 2017-10-11 11:18:20 +01:00
parent 4e0a159db4
commit f017a94b7e
2 changed files with 0 additions and 91 deletions

View file

@ -1,28 +0,0 @@
settings = require "settings-sharelatex"
request = require "request"
logger = require "logger-sharelatex"
module.exports = HistoryManager =
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} #{url}")
logger.error err: error, project_id: project_id, "error flushing project in track-changes api"
callback(error)
archiveProject: (project_id, callback = ()->)->
logger.log project_id: project_id, "archving project in track-changes api"
url = "#{settings.apis.trackchanges.url}/project/#{project_id}/archive"
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} #{url}")
logger.error err: error, project_id: project_id, "error archving project in track-changes api"
callback(error)

View file

@ -1,63 +0,0 @@
chai = require('chai')
expect = chai.expect
chai.should()
sinon = require("sinon")
modulePath = "../../../../app/js/Features/History/HistoryManager"
SandboxedModule = require('sandboxed-module')
describe "HistoryManager", ->
beforeEach ->
@HistoryManager = 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()
@request.post = sinon.stub()
describe "flushProject", ->
describe "with a successful response code", ->
beforeEach ->
@request.post = sinon.stub().callsArgWith(1, null, statusCode: 204, "")
@HistoryManager.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, "")
@HistoryManager.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
describe "ArchiveProject", ->
it "should call the post endpoint", (done)->
@request.post.callsArgWith(1, null, {})
@HistoryManager.archiveProject @project_id, (err)=>
@request.post.calledWith("#{@settings.apis.trackchanges.url}/project/#{@project_id}/archive")
done()
it "should return an error on a non success", (done)->
@request.post.callsArgWith(1, null, {statusCode:500})
@HistoryManager.archiveProject @project_id, (err)=>
expect(err).to.exist
done()