 				@projectLocator.findElement = sinon.stub()
 				@projectLocator.findElement.withArgs({project: @project, element_id: @docId, type: 'docs'})
 					.callsArgWith(1, null, @doc, @path)
+				@projectLocator.findElement.withArgs({project: @project, element_id: folder_id, type:"folder"},)
+					.callsArgWith(1, null, @destFolder, @destFolderPath)
 				@ProjectEntityHandler.moveEntity project_id, @docId, folder_id, "docs", userId, done
 
 			it 'should find the doc to move', ->

			@ProjectEntityHandler.renameEntity project_id, @entity_id, @entityType, @newName, userId, =>
				@tpdsUpdateSender.moveEntity.calledWith({project_id:project_id, startPath:@path.fileSystem, endPath:"/oldnamepath/new.tex", project_name:@project.name, rev:4}).should.equal true
				done()

	describe "_insertDeletedDocReference", ->
		beforeEach ->

			@newName = "new.tex"
			@path = mongo: "mongo.path", fileSystem: "/oldnamepath/oldname"

			@project_id = project_id
			@project =
				_id: ObjectId(project_id)
				rootFolder: [_id:ObjectId()]
			@folder =
				_id: ObjectId()
				name: "someFolder"
				docs: [ {name: "another-doc.tex"} ]
				fileRefs: [ {name: "another-file.tex"} ]
				folders: [ {name: "another-folder"} ]
			@doc =
				_id: ObjectId()
				name: "new.tex"

			@ProjectGetter.getProject.callsArgWith(2, null, @project)
			@ProjectEntityHandler.getAllEntitiesFromProject = sinon.stub()
			@ProjectEntityHandler.getAllEntitiesFromProject
