2014-01-27 13:09:37 -05:00
|
|
|
sinon = require('sinon')
|
|
|
|
chai = require('chai')
|
|
|
|
should = chai.should()
|
|
|
|
expect = chai.expect
|
|
|
|
modulePath = "../../../../app/js/HttpController.js"
|
|
|
|
SandboxedModule = require('sandboxed-module')
|
|
|
|
|
|
|
|
describe "HttpController", ->
|
|
|
|
beforeEach ->
|
|
|
|
@HttpController = SandboxedModule.require modulePath, requires:
|
|
|
|
"logger-sharelatex": { log: sinon.stub() }
|
|
|
|
"./HistoryManager": @HistoryManager = {}
|
|
|
|
@doc_id = "doc-id-123"
|
|
|
|
@version = 42
|
|
|
|
@next = sinon.stub()
|
|
|
|
|
2014-02-26 06:34:56 -05:00
|
|
|
describe "flushUpdatesWithLock", ->
|
2014-01-27 13:09:37 -05:00
|
|
|
beforeEach ->
|
|
|
|
@req =
|
|
|
|
params:
|
|
|
|
doc_id: @doc_id
|
|
|
|
@res =
|
|
|
|
send: sinon.stub()
|
2014-02-26 06:34:56 -05:00
|
|
|
@HistoryManager.processUncompressedUpdatesWithLock = sinon.stub().callsArg(1)
|
|
|
|
@HttpController.flushUpdatesWithLock @req, @res, @next
|
2014-01-27 13:09:37 -05:00
|
|
|
|
2014-02-26 06:34:56 -05:00
|
|
|
it "should process the updates", ->
|
|
|
|
@HistoryManager.processUncompressedUpdatesWithLock
|
|
|
|
.calledWith(@doc_id)
|
2014-01-27 13:09:37 -05:00
|
|
|
.should.equal true
|
|
|
|
|
|
|
|
it "should return a success code", ->
|
|
|
|
@res.send.calledWith(204).should.equal true
|