mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #7125 from overleaf/jk-project-rename-strip-ends
[web] Rename project: trim whitespace on ends GitOrigin-RevId: 2499d9e206ed5c929870a0f50cccd07ce3ec5ba7
This commit is contained in:
parent
b5677742a2
commit
e536ed1661
2 changed files with 12 additions and 0 deletions
|
@ -97,6 +97,7 @@ async function setProjectDescription(projectId, description) {
|
|||
}
|
||||
}
|
||||
async function renameProject(projectId, newName) {
|
||||
newName = newName.trim()
|
||||
await validateProjectName(newName)
|
||||
logger.log({ projectId, newName }, 'renaming project')
|
||||
let project
|
||||
|
|
|
@ -186,6 +186,17 @@ describe('ProjectDetailsHandler', function () {
|
|||
expect(this.TpdsUpdateSender.promises.moveEntity).not.to.have.been.called
|
||||
expect(this.ProjectModel.updateOne).not.to.have.been.called
|
||||
})
|
||||
|
||||
it('should trim whitespace around name', async function () {
|
||||
await this.handler.promises.renameProject(
|
||||
this.project._id,
|
||||
` ${this.newName} `
|
||||
)
|
||||
expect(this.ProjectModel.updateOne).to.have.been.calledWith(
|
||||
{ _id: this.project._id },
|
||||
{ name: this.newName }
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe('validateProjectName', function () {
|
||||
|
|
Loading…
Reference in a new issue