diff --git a/services/web/app/coffee/Features/Project/ProjectCreationHandler.coffee b/services/web/app/coffee/Features/Project/ProjectCreationHandler.coffee index dfc6313983..1bf84e6751 100644 --- a/services/web/app/coffee/Features/Project/ProjectCreationHandler.coffee +++ b/services/web/app/coffee/Features/Project/ProjectCreationHandler.coffee @@ -15,28 +15,28 @@ _ = require "underscore" module.exports = ProjectCreationHandler = - createBlankProject : (owner_id, projectName, overleafId, callback = (error, project) ->)-> + createBlankProject : (owner_id, projectName, projectHistoryId, callback = (error, project) ->)-> metrics.inc("project-creation") if arguments.length == 3 - callback = overleafId - overleafId = null + callback = projectHistoryId + projectHistoryId = null ProjectDetailsHandler.validateProjectName projectName, (error) -> return callback(error) if error? logger.log owner_id:owner_id, projectName:projectName, "creating blank project" - if overleafId? - ProjectCreationHandler._createBlankProject owner_id, projectName, overleafId, callback + if projectHistoryId? + ProjectCreationHandler._createBlankProject owner_id, projectName, projectHistoryId, callback else HistoryController.initializeProject (error, history) -> return callback(error) if error? ProjectCreationHandler._createBlankProject owner_id, projectName, history.overleaf_id, callback - _createBlankProject : (owner_id, projectName, overleafId, callback = (error, project) ->)-> + _createBlankProject : (owner_id, projectName, projectHistoryId, callback = (error, project) ->)-> rootFolder = new Folder {'name':'rootFolder'} project = new Project owner_ref : new ObjectId(owner_id) name : projectName - project.overleaf.id = overleafId + project.overleaf.history.id = projectHistoryId if Settings.currentImageName? project.imageName = Settings.currentImageName project.rootFolder[0] = rootFolder diff --git a/services/web/app/coffee/models/Project.coffee b/services/web/app/coffee/models/Project.coffee index f4f3cbbdc4..d60fb1be22 100644 --- a/services/web/app/coffee/models/Project.coffee +++ b/services/web/app/coffee/models/Project.coffee @@ -38,6 +38,8 @@ ProjectSchema = new Schema imported_at_ver_id : { type: Number } token : { type: String } read_token : { type: String } + history : + id : { type: Number } ProjectSchema.statics.getProject = (project_or_id, fields, callback)-> if project_or_id._id? diff --git a/services/web/test/UnitTests/coffee/Project/ProjectCreationHandlerTests.coffee b/services/web/test/UnitTests/coffee/Project/ProjectCreationHandlerTests.coffee index e9a746fc3d..5c32db63d3 100644 --- a/services/web/test/UnitTests/coffee/Project/ProjectCreationHandlerTests.coffee +++ b/services/web/test/UnitTests/coffee/Project/ProjectCreationHandlerTests.coffee @@ -22,7 +22,8 @@ describe 'ProjectCreationHandler', -> @._id = project_id @owner_ref = options.owner_ref @name = options.name - @overleaf = {} + @overleaf = + history: {} save: sinon.stub().callsArg(0) rootFolder:[{ _id: rootFolderId @@ -86,13 +87,13 @@ describe 'ProjectCreationHandler', -> it "should set the overleaf id if overleaf id not provided", (done)-> @handler.createBlankProject ownerId, projectName, (err, project)=> - project.overleaf.id.should.equal @overleaf_id + project.overleaf.history.id.should.equal @overleaf_id done() it "should set the overleaf id if overleaf id provided", (done)-> overleaf_id = 2345 @handler.createBlankProject ownerId, projectName, overleaf_id, (err, project)-> - project.overleaf.id.should.equal overleaf_id + project.overleaf.history.id.should.equal overleaf_id done() it "should set the language from the user", (done)->