mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-29 07:13:39 -05:00
Log out errors when null docs are encountered
This commit is contained in:
parent
43ed71e82c
commit
0adcf3c140
2 changed files with 82 additions and 35 deletions
|
@ -22,6 +22,8 @@ module.exports = HttpController =
|
||||||
for doc in docs
|
for doc in docs
|
||||||
if doc? # There can end up being null docs for some reason :( (probably a race condition)
|
if doc? # There can end up being null docs for some reason :( (probably a race condition)
|
||||||
docViews.push HttpController._buildDocView(doc)
|
docViews.push HttpController._buildDocView(doc)
|
||||||
|
else
|
||||||
|
logger.error err: new Error("null doc"), project_id: project_id, "encountered null doc"
|
||||||
res.json docViews
|
res.json docViews
|
||||||
|
|
||||||
updateDoc: (req, res, next = (error) ->) ->
|
updateDoc: (req, res, next = (error) ->) ->
|
||||||
|
|
|
@ -47,6 +47,7 @@ describe "HttpController", ->
|
||||||
.should.equal true
|
.should.equal true
|
||||||
|
|
||||||
describe "getAllDocs", ->
|
describe "getAllDocs", ->
|
||||||
|
describe "normally", ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
@req.params =
|
@req.params =
|
||||||
project_id: @project_id
|
project_id: @project_id
|
||||||
|
@ -84,6 +85,50 @@ describe "HttpController", ->
|
||||||
}])
|
}])
|
||||||
.should.equal true
|
.should.equal true
|
||||||
|
|
||||||
|
describe "with a null doc", ->
|
||||||
|
beforeEach ->
|
||||||
|
@req.params =
|
||||||
|
project_id: @project_id
|
||||||
|
@docs = [{
|
||||||
|
_id: ObjectId()
|
||||||
|
lines: ["mock", "lines", "one"]
|
||||||
|
version: 1
|
||||||
|
rev: 2
|
||||||
|
},
|
||||||
|
null,
|
||||||
|
{
|
||||||
|
_id: ObjectId()
|
||||||
|
lines: ["mock", "lines", "two"]
|
||||||
|
version: 3
|
||||||
|
rev: 4
|
||||||
|
}]
|
||||||
|
@DocManager.getAllDocs = sinon.stub().callsArgWith(1, null, @docs)
|
||||||
|
@HttpController.getAllDocs @req, @res, @next
|
||||||
|
|
||||||
|
it "should return the non null docs as JSON", ->
|
||||||
|
@res.json
|
||||||
|
.calledWith([{
|
||||||
|
_id: @docs[0]._id.toString()
|
||||||
|
lines: @docs[0].lines
|
||||||
|
rev: @docs[0].rev
|
||||||
|
version: @docs[0].version
|
||||||
|
}, {
|
||||||
|
_id: @docs[2]._id.toString()
|
||||||
|
lines: @docs[2].lines
|
||||||
|
rev: @docs[2].rev
|
||||||
|
version: @docs[2].version
|
||||||
|
}])
|
||||||
|
.should.equal true
|
||||||
|
|
||||||
|
it "should log out an error", ->
|
||||||
|
@logger.error
|
||||||
|
.calledWith(
|
||||||
|
err: new Error("null doc")
|
||||||
|
project_id: @project_id
|
||||||
|
"encountered null doc"
|
||||||
|
)
|
||||||
|
.should.equal true
|
||||||
|
|
||||||
describe "updateDoc", ->
|
describe "updateDoc", ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
@req.params =
|
@req.params =
|
||||||
|
|
Loading…
Reference in a new issue