Don't error on project clone if not root doc is set

This commit is contained in:
James Allen
2015-09-02 14:32:21 +01:00
parent 40704b486e
commit 639424f664
2 changed files with 11 additions and 1 deletions
@@ -54,7 +54,10 @@ module.exports =
findRootDoc : (opts, callback)->
getRootDoc = (project)=>
@findElement {project:project, element_id:project.rootDoc_id, type:"docs"}, callback
if project.rootDoc_id?
@findElement {project:project, element_id:project.rootDoc_id, type:"docs"}, callback
else
callback null, null
{project, project_id} = opts
if project?
getRootDoc project
@@ -159,6 +159,13 @@ describe 'project model', ->
assert !err?
doc._id.should.equal rootDoc._id
done()
it 'should return null when the project has no rootDoc', (done) ->
project.rootDoc_id = null
@locator.findRootDoc project, (err, doc)->
assert !err?
expect(doc).to.equal null
done()
describe 'findElementByPath', ->