avoid clobbering imported image names

This commit is contained in:
Brian Gough 2018-08-06 16:56:44 +01:00
parent 2626382024
commit efcd3577ce
2 changed files with 11 additions and 2 deletions

View file

@ -55,7 +55,8 @@ module.exports = ProjectCreationHandler =
if Settings.apis?.project_history?.displayHistoryForNewProjects
project.overleaf.history.display = true
if Settings.currentImageName?
project.imageName = Settings.currentImageName
# avoid clobbering any imageName already set in attributes (e.g. importedImageName)
project.imageName ?= Settings.currentImageName
project.rootFolder[0] = rootFolder
User.findById owner_id, "ace.spellCheckLanguage", (err, user)->
project.spellCheckLanguage = user.ace.spellCheckLanguage

View file

@ -111,7 +111,7 @@ describe 'ProjectCreationHandler', ->
project.spellCheckLanguage.should.equal "de"
done()
it "should set the imageName to currentImageName if set", (done) ->
it "should set the imageName to currentImageName if set and no imageName attribute", (done) ->
@Settings.currentImageName = "mock-image-name"
@handler.createBlankProject ownerId, projectName, (err, project)=>
project.imageName.should.equal @Settings.currentImageName
@ -123,6 +123,14 @@ describe 'ProjectCreationHandler', ->
expect(project.imageName).to.not.exist
done()
it "should set the imageName to the attribute value if set and not overwrite it with the currentImageName", (done) ->
@Settings.currentImageName = "mock-image-name"
attributes =
imageName: "attribute-image-name"
@handler.createBlankProject ownerId, projectName, attributes, (err, project)=>
project.imageName.should.equal attributes.imageName
done()
it "should not set the overleaf.history.display if not configured in settings", (done) ->
@Settings.apis.project_history.displayHistoryForNewProjects = false
@handler.createBlankProject ownerId, projectName, (err, project)=>