mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-24 03:33:27 +00:00
if projectId is not defined, error out
This commit is contained in:
parent
b8e4cafd81
commit
08567ff220
2 changed files with 18 additions and 0 deletions
|
@ -6,6 +6,8 @@ module.exports = CooldownMiddlewear =
|
|||
|
||||
freezeProject: (req, res, next) ->
|
||||
projectId = req.params.Project_id
|
||||
if !projectId?
|
||||
return next(new Error('[Cooldown] No projectId parameter on route'))
|
||||
CooldownManager.isProjectOnCooldown projectId, (err, projectIsOnCooldown) ->
|
||||
if err?
|
||||
return next(err)
|
||||
|
|
|
@ -70,3 +70,19 @@ describe "CooldownMiddlewear", ->
|
|||
@CooldownMiddlewear.freezeProject @req, @res, @next
|
||||
@next.callCount.should.equal 1
|
||||
expect(@next.lastCall.args[0]).to.be.instanceof Error
|
||||
|
||||
describe 'when projectId is not part of route', ->
|
||||
beforeEach ->
|
||||
@CooldownManager.isProjectOnCooldown = sinon.stub().callsArgWith(1, null, true)
|
||||
@req = {params: {lol: 'abc'}}
|
||||
@res = {sendStatus: sinon.stub()}
|
||||
@next = sinon.stub()
|
||||
|
||||
it 'call next with an error', ->
|
||||
@CooldownMiddlewear.freezeProject @req, @res, @next
|
||||
@next.callCount.should.equal 1
|
||||
expect(@next.lastCall.args[0]).to.be.instanceof Error
|
||||
|
||||
it 'should not call CooldownManager.isProjectOnCooldown', ->
|
||||
@CooldownMiddlewear.freezeProject @req, @res, @next
|
||||
@CooldownManager.isProjectOnCooldown.callCount.should.equal 0
|
||||
|
|
Loading…
Reference in a new issue