Преглед изворни кода

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

James Allen пре 11 година
родитељ
комит
639424f664

+ 4 - 1
services/web/app/coffee/Features/Project/ProjectLocator.coffee

@@ -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

+ 7 - 0
services/web/test/UnitTests/coffee/Project/ProjectLocatorTests.coffee

@@ -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', ->