diff --git a/services/web/app/coffee/Features/Project/ProjectEntityUpdateHandler.coffee b/services/web/app/coffee/Features/Project/ProjectEntityUpdateHandler.coffee index 7a50a6b096..ff09eda64d 100644 --- a/services/web/app/coffee/Features/Project/ProjectEntityUpdateHandler.coffee +++ b/services/web/app/coffee/Features/Project/ProjectEntityUpdateHandler.coffee @@ -319,7 +319,7 @@ module.exports = ProjectEntityUpdateHandler = self = ProjectGetter.getProject project_id, rootFolder: true, overleaf: true, (error, project) -> return callback(error) if error? - if !project.overleaf?.history?.id? + if !project?.overleaf?.history?.id? error = new Errors.ProjectHistoryDisabledError("project history not enabled for #{project_id}") return callback(error) @@ -335,8 +335,7 @@ module.exports = ProjectEntityUpdateHandler = self = path: file.path url: FileStoreHandler._buildUrl(project_id, file.file._id) - DocumentUpdaterHandler.resyncProjectHistory project_id, docs, files, callback - + DocumentUpdaterHandler.resyncProjectHistory project_id, docs, files, callback _cleanUpEntity: (project, entity, entityType, path, userId, callback = (error) ->) -> if(entityType.indexOf("file") != -1) self._cleanUpFile project, entity, path, userId, callback diff --git a/services/web/test/unit/coffee/Project/ProjectEntityUpdateHandlerTests.coffee b/services/web/test/unit/coffee/Project/ProjectEntityUpdateHandlerTests.coffee index 4951d6508d..9d3651f55d 100644 --- a/services/web/test/unit/coffee/Project/ProjectEntityUpdateHandlerTests.coffee +++ b/services/web/test/unit/coffee/Project/ProjectEntityUpdateHandlerTests.coffee @@ -746,6 +746,16 @@ describe 'ProjectEntityUpdateHandler', -> .should.equal true describe "resyncProjectHistory", -> + describe "a deleted project", -> + beforeEach -> + @ProjectGetter.getProject = sinon.stub().yields() + + @ProjectEntityUpdateHandler.resyncProjectHistory project_id, @callback + + it "should return an error", -> + error = new Errors.ProjectHistoryDisabledError("project history not enabled for #{project_id}") + @callback.calledWith(error).should.equal true + describe "a project without project-history enabled", -> beforeEach -> @project.ovreleaf = {}