mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
add unit tests for skipping history flush
This commit is contained in:
parent
7493462154
commit
e75f2cc325
2 changed files with 33 additions and 0 deletions
|
@ -46,6 +46,28 @@ describe "HistoryManager", ->
|
|||
.calledWith({url: "#{@Settings.apis.project_history.url}/project/#{@project_id}/flush", qs:{background:true}})
|
||||
.should.equal true
|
||||
|
||||
describe "flushProjectChanges", ->
|
||||
|
||||
describe "in the normal case", ->
|
||||
beforeEach ->
|
||||
@request.post = sinon.stub().callsArgWith(1, null, statusCode: 204)
|
||||
@HistoryManager.flushProjectChanges @project_id, {background:true}
|
||||
|
||||
it "should send a request to the project history api", ->
|
||||
@request.post
|
||||
.calledWith({url: "#{@Settings.apis.project_history.url}/project/#{@project_id}/flush", qs:{background:true}})
|
||||
.should.equal true
|
||||
|
||||
describe "with the skip_history_flush option", ->
|
||||
beforeEach ->
|
||||
@request.post = sinon.stub()
|
||||
@HistoryManager.flushProjectChanges @project_id, {skip_history_flush:true}
|
||||
|
||||
it "should not send a request to the project history api", ->
|
||||
@request.post
|
||||
.called
|
||||
.should.equal false
|
||||
|
||||
describe "recordAndFlushHistoryOps", ->
|
||||
beforeEach ->
|
||||
@ops = [ 'mock-ops' ]
|
||||
|
|
|
@ -343,6 +343,17 @@ describe "HttpController", ->
|
|||
it "should time the request", ->
|
||||
@Metrics.Timer::done.called.should.equal true
|
||||
|
||||
describe "with the shutdown=true option from realtime", ->
|
||||
beforeEach ->
|
||||
@ProjectManager.flushAndDeleteProjectWithLocks = sinon.stub().callsArgWith(2)
|
||||
@req.query = {background:true, shutdown:true}
|
||||
@HttpController.deleteProject(@req, @res, @next)
|
||||
|
||||
it "should pass the skip_history_flush option when flushing the project", ->
|
||||
@ProjectManager.flushAndDeleteProjectWithLocks
|
||||
.calledWith(@project_id, {background:true, skip_history_flush:true})
|
||||
.should.equal true
|
||||
|
||||
describe "when an errors occurs", ->
|
||||
beforeEach ->
|
||||
@ProjectManager.flushAndDeleteProjectWithLocks = sinon.stub().callsArgWith(2, new Error("oops"))
|
||||
|
|
Loading…
Reference in a new issue