Merge pull request #30418 from overleaf/mfb-improve-handling-of-debug-copies-of-user-projects
Add isDebugCopyOf property to project, add Debug tag to debug project. GitOrigin-RevId: e3d17de05c6f31db16b861d1adae333211dff018
This commit is contained in:
committed by
Copybot
parent
5829a7fe43
commit
a591f2eb7a
@@ -20,10 +20,13 @@ describe('ProjectGetter', function () {
|
||||
ctx.Project = {
|
||||
find: sinon.stub().returns({
|
||||
exec: sinon.stub().resolves(),
|
||||
populate: sinon.stub().returnsThis(),
|
||||
limit: sinon.stub().returnsThis(),
|
||||
}),
|
||||
findOne: sinon.stub().returns({
|
||||
exec: sinon.stub().resolves(ctx.project),
|
||||
}),
|
||||
exists: sinon.stub().returns({ exec: sinon.stub().resolves(true) }),
|
||||
}
|
||||
ctx.CollaboratorsGetter = {
|
||||
promises: {
|
||||
@@ -458,4 +461,39 @@ describe('ProjectGetter', function () {
|
||||
expect(docs).to.deep.equal([ctx.deletedProject])
|
||||
})
|
||||
})
|
||||
|
||||
describe('findAllDebugProjects', function () {
|
||||
it('should find all projects with overleaf.isDebugCopyOf of type objectId', async function (ctx) {
|
||||
await ctx.ProjectGetter.promises.findAllDebugProjects('fields')
|
||||
sinon.assert.calledWith(ctx.Project.find, {
|
||||
'overleaf.isDebugCopyOf': { $type: 'objectId' },
|
||||
})
|
||||
sinon.assert.calledWith(ctx.Project.find().populate, 'owner_ref', [
|
||||
'email',
|
||||
'name',
|
||||
])
|
||||
sinon.assert.calledOnce(ctx.Project.find().exec)
|
||||
})
|
||||
})
|
||||
|
||||
describe('existUsersDebugProjectsOlderThan', function () {
|
||||
it('should check for existence of debug projects older than given days', async function (ctx) {
|
||||
const days = 10
|
||||
const cutoffDate = new Date(Date.now() - days * 24 * 60 * 60 * 1000)
|
||||
|
||||
const exists =
|
||||
await ctx.ProjectGetter.promises.existUsersDebugProjectsOlderThan(
|
||||
ctx.userId,
|
||||
days
|
||||
)
|
||||
|
||||
sinon.assert.calledWith(ctx.Project.exists, {
|
||||
owner_ref: ctx.userId,
|
||||
'overleaf.isDebugCopyOf': { $type: 'objectId' },
|
||||
lastUpdated: { $lt: cutoffDate },
|
||||
})
|
||||
|
||||
expect(exists).to.equal(true)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user