mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Send an empty keys array when there is no data
This commit is contained in:
parent
8492ea7d28
commit
e46901a21b
2 changed files with 5 additions and 4 deletions
|
@ -32,8 +32,8 @@ module.exports = ReferencesController =
|
||||||
|
|
||||||
_handleIndexResponse: (req, res, projectId, shouldBroadcast, data) ->
|
_handleIndexResponse: (req, res, projectId, shouldBroadcast, data) ->
|
||||||
if !data? or !data.keys?
|
if !data? or !data.keys?
|
||||||
return res.send()
|
return res.json({projectId, keys: []})
|
||||||
else if shouldBroadcast
|
if shouldBroadcast
|
||||||
logger.log {projectId}, "emitting new references keys to connected clients"
|
logger.log {projectId}, "emitting new references keys to connected clients"
|
||||||
EditorRealTimeController.emitToRoom projectId, 'references:keys:updated', data.keys
|
EditorRealTimeController.emitToRoom projectId, 'references:keys:updated', data.keys
|
||||||
return res.json data
|
return res.json data
|
||||||
|
|
|
@ -134,9 +134,10 @@ describe "ReferencesController", ->
|
||||||
@res.sendStatus.calledWith(400).should.equal false
|
@res.sendStatus.calledWith(400).should.equal false
|
||||||
done()
|
done()
|
||||||
|
|
||||||
it 'should close the response', (done) ->
|
it 'should send a response with an empty keys list', (done) ->
|
||||||
@call () =>
|
@call () =>
|
||||||
@res.send.called.should.equal true
|
@res.json.called.should.equal true
|
||||||
|
@res.json.calledWith({projectId: @projectId, keys: []}).should.equal true
|
||||||
done()
|
done()
|
||||||
|
|
||||||
describe 'index', ->
|
describe 'index', ->
|
||||||
|
|
Loading…
Reference in a new issue