Merge pull request #2639 from overleaf/em-convert-doc-to-file

Endpoint for converting a doc to a file

GitOrigin-RevId: 0a3bd46a7a78537b0f64dc577402277cbe81fecb
This commit is contained in:
Eric Mc Sween
2020-03-04 04:37:43 -05:00
committed by Copybot
parent 693100358c
commit 2627595040
9 changed files with 1011 additions and 615 deletions

View File

@@ -1089,4 +1089,27 @@ describe('ProjectEntityMongoUpdateHandler', function() {
})
})
})
describe('replaceDocWithFile', function() {
it('should simultaneously remove the doc and add the file', async function() {
this.ProjectMock.expects('findOneAndUpdate')
.withArgs(
{ _id: this.project._id },
{
$pull: { 'rootFolder.0.docs': { _id: this.doc._id } },
$push: { 'rootFolder.0.fileRefs': this.file },
$inc: { version: 1 }
},
{ new: true }
)
.chain('exec')
.resolves(this.project)
await this.subject.promises.replaceDocWithFile(
this.project._id,
this.doc._id,
this.file
)
this.ProjectMock.verify()
})
})
})