Merge pull request #2724 from overleaf/ns-doc-over-file

allow upload of doc over existing file

GitOrigin-RevId: 13578bf4ab6d54686077402488399db0379cc761
This commit is contained in:
Alasdair Smith
2020-04-27 14:00:56 +01:00
committed by Copybot
parent be900488a9
commit 3a1ab63cce
4 changed files with 237 additions and 13 deletions
@@ -1113,4 +1113,27 @@ describe('ProjectEntityMongoUpdateHandler', function() {
this.ProjectMock.verify()
})
})
describe('replaceFileWithDoc', function() {
it('should simultaneously remove the file and add the doc', async function() {
this.ProjectMock.expects('findOneAndUpdate')
.withArgs(
{ _id: this.project._id },
{
$pull: { 'rootFolder.0.fileRefs': { _id: this.file._id } },
$push: { 'rootFolder.0.docs': this.doc },
$inc: { version: 1 }
},
{ new: true }
)
.chain('exec')
.resolves(this.project)
await this.subject.promises.replaceFileWithDoc(
this.project._id,
this.file._id,
this.doc
)
this.ProjectMock.verify()
})
})
})