diff --git a/services/web/app/coffee/Features/Compile/ClsiManager.coffee b/services/web/app/coffee/Features/Compile/ClsiManager.coffee index e03916c0fe..fd65454054 100755 --- a/services/web/app/coffee/Features/Compile/ClsiManager.coffee +++ b/services/web/app/coffee/Features/Compile/ClsiManager.coffee @@ -59,7 +59,7 @@ module.exports = ClsiManager = VALID_COMPILERS: ["pdflatex", "latex", "xelatex", "lualatex"] _buildRequest: (project_id, settingsOverride={}, callback = (error, request) ->) -> - Project.findById project_id, {compiler: 1, rootDoc_id: 1}, (error, project) -> + Project.findById project_id, {compiler: 1, rootDoc_id: 1, imageName: 1}, (error, project) -> return callback(error) if error? return callback(new Errors.NotFoundError("project does not exist: #{project_id}")) if !project? @@ -102,6 +102,7 @@ module.exports = ClsiManager = options: compiler: project.compiler timeout: settingsOverride.timeout + imageName: project.imageName rootResourcePath: rootResourcePath resources: resources } diff --git a/services/web/app/coffee/Features/Project/ProjectCreationHandler.coffee b/services/web/app/coffee/Features/Project/ProjectCreationHandler.coffee index c461c04341..ad32a4d7a2 100644 --- a/services/web/app/coffee/Features/Project/ProjectCreationHandler.coffee +++ b/services/web/app/coffee/Features/Project/ProjectCreationHandler.coffee @@ -19,6 +19,8 @@ module.exports = project = new Project owner_ref : new ObjectId(owner_id) name : projectName + if Settings.currentImageName? + project.imageName = Settings.currentImageName project.rootFolder[0] = rootFolder User.findById owner_id, "ace.spellCheckLanguage", (err, user)-> project.spellCheckLanguage = user.ace.spellCheckLanguage diff --git a/services/web/app/coffee/models/Project.coffee b/services/web/app/coffee/models/Project.coffee index 111ef40cfb..77fbdaf1d4 100644 --- a/services/web/app/coffee/models/Project.coffee +++ b/services/web/app/coffee/models/Project.coffee @@ -31,6 +31,7 @@ ProjectSchema = new Schema description : {type:String, default:''} archived : { type: Boolean } deletedDocs : [DeletedDocSchema] + imageName : { type: String } ProjectSchema.statics.getProject = (project_or_id, fields, callback)-> if project_or_id._id? diff --git a/services/web/test/UnitTests/coffee/Compile/ClsiManagerTests.coffee b/services/web/test/UnitTests/coffee/Compile/ClsiManagerTests.coffee index 66c21c2400..e47f72daca 100644 --- a/services/web/test/UnitTests/coffee/Compile/ClsiManagerTests.coffee +++ b/services/web/test/UnitTests/coffee/Compile/ClsiManagerTests.coffee @@ -109,6 +109,7 @@ describe "ClsiManager", -> _id: @project_id compiler: @compiler = "latex" rootDoc_id: "mock-doc-id-1" + imageName: @image = "mock-image-name" @docs = { "/main.tex": @doc_1 = { @@ -145,7 +146,7 @@ describe "ClsiManager", -> it "should get the project with the required fields", -> @Project.findById - .calledWith(@project_id, {compiler:1, rootDoc_id: 1}) + .calledWith(@project_id, {compiler:1, rootDoc_id: 1, imageName: 1}) .should.equal true it "should get all the docs", -> @@ -164,6 +165,7 @@ describe "ClsiManager", -> options: compiler: @compiler timeout : 100 + imageName: @image rootResourcePath: "main.tex" resources: [{ path: "main.tex" diff --git a/services/web/test/UnitTests/coffee/Project/ProjectCreationHandlerTests.coffee b/services/web/test/UnitTests/coffee/Project/ProjectCreationHandlerTests.coffee index d6004bffa2..5ce1d5687d 100644 --- a/services/web/test/UnitTests/coffee/Project/ProjectCreationHandlerTests.coffee +++ b/services/web/test/UnitTests/coffee/Project/ProjectCreationHandlerTests.coffee @@ -2,6 +2,7 @@ spies = require('chai-spies') chai = require('chai').use(spies) sinon = require("sinon") should = chai.should() +expect = chai.expect modulePath = "../../../../app/js/Features/Project/ProjectCreationHandler.js" SandboxedModule = require('sandboxed-module') Settings = require('settings-sharelatex') @@ -47,6 +48,7 @@ describe 'ProjectCreationHandler', -> '../../models/Project':{Project:@ProjectModel} '../../models/Folder':{Folder:@FolderModel} './ProjectEntityHandler':@ProjectEntityHandler + "settings-sharelatex": @Settings = {} 'logger-sharelatex': {log:->} describe 'Creating a Blank project', -> @@ -70,6 +72,18 @@ describe 'ProjectCreationHandler', -> @handler.createBlankProject ownerId, projectName, (err, project)-> project.spellCheckLanguage.should.equal "de" done() + + it "should set the imageName to currentImageName if set", (done) -> + @Settings.currentImageName = "mock-image-name" + @handler.createBlankProject ownerId, projectName, (err, project)=> + project.imageName.should.equal @Settings.currentImageName + done() + + it "should not set the imageName if no currentImageName", (done) -> + @Settings.currentImageName = null + @handler.createBlankProject ownerId, projectName, (err, project)=> + expect(project.imageName).to.not.exist + done() describe "with an error", -> beforeEach ->