mirror of
https://github.com/overleaf/overleaf.git
synced 2025-04-05 13:59:39 +00:00
check that element being inserted has an _id
This commit is contained in:
parent
f24bc2c501
commit
ba9bc3a2e8
2 changed files with 8 additions and 1 deletions
|
@ -501,7 +501,7 @@ module.exports = ProjectEntityHandler =
|
|||
elementType = "fileRefs"
|
||||
return elementType
|
||||
|
||||
if !element?
|
||||
if !element? or !element._id?
|
||||
e = new Error("no element passed to be inserted")
|
||||
logger.err project_id:project._id, folder_id:folder_id, element:element, type:type, "failed trying to insert element as it was null"
|
||||
return callback(e)
|
||||
|
|
|
@ -1048,6 +1048,13 @@ describe 'ProjectEntityHandler', ->
|
|||
@projectLocator.findElement.args[0][0].element_id.should.equal @project.rootFolder[0]._id
|
||||
done()
|
||||
|
||||
it "should error if the element has no _id", (done)->
|
||||
doc =
|
||||
name:"something"
|
||||
@ProjectEntityHandler._putElement @project, @folder._id, doc, "doc", (err)=>
|
||||
@ProjectModel.update.called.should.equal false
|
||||
done()
|
||||
|
||||
|
||||
|
||||
describe "_countElements", ->
|
||||
|
|
Loading…
Reference in a new issue