404 when resyncing deleting projects

This commit is contained in:
Hayden Faulds 2018-03-16 15:26:19 +00:00
parent f514b68936
commit 57de597e60
2 changed files with 12 additions and 3 deletions

View file

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

View file

@ -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 = {}