ProjectDeleter.archiveProject doesn't need to get entire project

This commit is contained in:
Henry Oswald 2016-02-26 08:13:41 +00:00
parent 447568aa91
commit b6d62a677b
2 changed files with 6 additions and 1 deletions

View file

@ -1,4 +1,5 @@
Project = require('../../models/Project').Project
ProjectGetter = require("./ProjectGetter")
logger = require('logger-sharelatex')
documentUpdaterHandler = require('../DocumentUpdater/DocumentUpdaterHandler')
tagsHandler = require("../Tags/TagsHandler")
@ -34,7 +35,7 @@ module.exports = ProjectDeleter =
archiveProject: (project_id, callback = (error) ->)->
logger.log project_id:project_id, "deleting project"
Project.findById project_id, (err, project)=>
ProjectGetter.getProject project_id, {owner_ref:1, collaberator_refs:1, readOnly_refs:1}, (err, project)=>
if err? or !project?
logger.err err:err, project_id:project_id, "error getting project to delete it"
callback(err)

View file

@ -25,12 +25,15 @@ describe 'ProjectDeleter', ->
@editorController = notifyUsersProjectHasBeenDeletedOrRenamed : sinon.stub().callsArgWith(1)
@TagsHandler =
removeProjectFromAllTags: sinon.stub().callsArgWith(2)
@ProjectGetter =
getProject:sinon.stub()
@deleter = SandboxedModule.require modulePath, requires:
"../Editor/EditorController": @editorController
'../../models/Project':{Project:@Project}
'../DocumentUpdater/DocumentUpdaterHandler': @documentUpdaterHandler
"../Tags/TagsHandler":@TagsHandler
"../FileStore/FileStoreHandler": @FileStoreHandler = {}
"./ProjectGetter": @ProjectGetter
'logger-sharelatex':
log:->
@ -89,6 +92,7 @@ describe 'ProjectDeleter', ->
describe "archiveProject", ->
beforeEach ->
@ProjectGetter.getProject.callsArgWith(2, null, @project)
@Project.update.callsArgWith(2)
it "should flushProjectToMongoAndDelete in doc updater", (done)->