mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #4254 from overleaf/em-active-projects-expire
Unit test for not expiring active projects GitOrigin-RevId: 8b2f3d05c7f7e4c4d44e5487041f19d2bff9891a
This commit is contained in:
parent
a966a5f9d7
commit
9820b787a7
1 changed files with 93 additions and 51 deletions
|
@ -419,70 +419,112 @@ describe('ProjectDeleter', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('expireDeletedProject', function () {
|
describe('expireDeletedProject', function () {
|
||||||
beforeEach(async function () {
|
describe('on an inactive project', function () {
|
||||||
for (const deletedProject of this.deletedProjects) {
|
beforeEach(async function () {
|
||||||
this.ProjectMock.expects('findById')
|
this.ProjectMock.expects('findById')
|
||||||
.withArgs(deletedProject.deleterData.deletedProjectId)
|
.withArgs(this.deletedProjects[0].deleterData.deletedProjectId)
|
||||||
.chain('exec')
|
.chain('exec')
|
||||||
.resolves(null)
|
.resolves(null)
|
||||||
}
|
this.DeletedProjectMock.expects('updateOne')
|
||||||
this.DeletedProjectMock.expects('updateOne')
|
.withArgs(
|
||||||
.withArgs(
|
{
|
||||||
{
|
_id: this.deletedProjects[0]._id,
|
||||||
_id: this.deletedProjects[0]._id,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
$set: {
|
|
||||||
'deleterData.deleterIpAddress': null,
|
|
||||||
project: null,
|
|
||||||
},
|
},
|
||||||
}
|
{
|
||||||
|
$set: {
|
||||||
|
'deleterData.deleterIpAddress': null,
|
||||||
|
project: null,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.chain('exec')
|
||||||
|
.resolves()
|
||||||
|
|
||||||
|
this.DeletedProjectMock.expects('findOne')
|
||||||
|
.withArgs({
|
||||||
|
'deleterData.deletedProjectId': this.deletedProjects[0].project._id,
|
||||||
|
})
|
||||||
|
.chain('exec')
|
||||||
|
.resolves(this.deletedProjects[0])
|
||||||
|
|
||||||
|
await this.ProjectDeleter.promises.expireDeletedProject(
|
||||||
|
this.deletedProjects[0].project._id
|
||||||
)
|
)
|
||||||
.chain('exec')
|
})
|
||||||
.resolves()
|
|
||||||
|
|
||||||
this.DeletedProjectMock.expects('findOne')
|
it('should find the specified deletedProject and remove its project and ip address', function () {
|
||||||
.withArgs({
|
this.DeletedProjectMock.verify()
|
||||||
'deleterData.deletedProjectId': this.deletedProjects[0].project._id,
|
})
|
||||||
|
|
||||||
|
it('should destroy the docs in docstore', function () {
|
||||||
|
expect(
|
||||||
|
this.DocstoreManager.promises.destroyProject
|
||||||
|
).to.have.been.calledWith(this.deletedProjects[0].project._id)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should delete the project in history', function () {
|
||||||
|
expect(
|
||||||
|
this.HistoryManager.promises.deleteProject
|
||||||
|
).to.have.been.calledWith(
|
||||||
|
this.deletedProjects[0].project._id,
|
||||||
|
this.deletedProjects[0].project.overleaf.history.id
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should destroy the files in filestore', function () {
|
||||||
|
expect(
|
||||||
|
this.FileStoreHandler.promises.deleteProject
|
||||||
|
).to.have.been.calledWith(this.deletedProjects[0].project._id)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should destroy the files in project-archiver', function () {
|
||||||
|
expect(
|
||||||
|
this.TpdsUpdateSender.promises.deleteProject
|
||||||
|
).to.have.been.calledWith({
|
||||||
|
project_id: this.deletedProjects[0].project._id,
|
||||||
})
|
})
|
||||||
.chain('exec')
|
})
|
||||||
.resolves(this.deletedProjects[0])
|
|
||||||
|
|
||||||
await this.ProjectDeleter.promises.expireDeletedProject(
|
|
||||||
this.deletedProjects[0].project._id
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should find the specified deletedProject and remove its project and ip address', function () {
|
describe('on an active project (from an incomplete delete)', function () {
|
||||||
this.DeletedProjectMock.verify()
|
beforeEach(async function () {
|
||||||
})
|
this.ProjectMock.expects('findById')
|
||||||
|
.withArgs(this.deletedProjects[0].deleterData.deletedProjectId)
|
||||||
|
.chain('exec')
|
||||||
|
.resolves(this.deletedProjects[0].project)
|
||||||
|
this.DeletedProjectMock.expects('deleteOne')
|
||||||
|
.withArgs({
|
||||||
|
'deleterData.deletedProjectId': this.deletedProjects[0].project._id,
|
||||||
|
})
|
||||||
|
.chain('exec')
|
||||||
|
.resolves()
|
||||||
|
await this.ProjectDeleter.promises.expireDeletedProject(
|
||||||
|
this.deletedProjects[0].project._id
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
it('should destroy the docs in docstore', function () {
|
it('should delete the spurious deleted project record', function () {
|
||||||
expect(
|
this.DeletedProjectMock.verify()
|
||||||
this.DocstoreManager.promises.destroyProject
|
})
|
||||||
).to.have.been.calledWith(this.deletedProjects[0].project._id)
|
|
||||||
})
|
|
||||||
|
|
||||||
it('should delete the project in history', function () {
|
it('should not destroy the docs in docstore', function () {
|
||||||
expect(
|
expect(this.DocstoreManager.promises.destroyProject).to.not.have.been
|
||||||
this.HistoryManager.promises.deleteProject
|
.called
|
||||||
).to.have.been.calledWith(
|
})
|
||||||
this.deletedProjects[0].project._id,
|
|
||||||
this.deletedProjects[0].project.overleaf.history.id
|
|
||||||
)
|
|
||||||
})
|
|
||||||
|
|
||||||
it('should destroy the files in filestore', function () {
|
it('should not delete the project in history', function () {
|
||||||
expect(
|
expect(this.HistoryManager.promises.deleteProject).to.not.have.been
|
||||||
this.FileStoreHandler.promises.deleteProject
|
.called
|
||||||
).to.have.been.calledWith(this.deletedProjects[0].project._id)
|
})
|
||||||
})
|
|
||||||
|
|
||||||
it('should destroy the files in project-archiver', function () {
|
it('should not destroy the files in filestore', function () {
|
||||||
expect(
|
expect(this.FileStoreHandler.promises.deleteProject).to.not.have.been
|
||||||
this.TpdsUpdateSender.promises.deleteProject
|
.called
|
||||||
).to.have.been.calledWith({
|
})
|
||||||
project_id: this.deletedProjects[0].project._id,
|
|
||||||
|
it('should not destroy the files in project-archiver', function () {
|
||||||
|
expect(this.TpdsUpdateSender.promises.deleteProject).to.not.have.been
|
||||||
|
.called
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue