mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-31 21:01:33 +02:00
Merge pull request #24614 from overleaf/rh-pending-reviewer-pull
Set null pendingReviewer_refs to empty array in removeUserFromProject GitOrigin-RevId: b21dd3f2febdb59dfafb45347960e375daeac463
This commit is contained in:
@@ -33,6 +33,12 @@ async function removeUserFromProject(projectId, userId) {
|
||||
try {
|
||||
const project = await Project.findOne({ _id: projectId }).exec()
|
||||
|
||||
// Temporary workaround for the case where pendingReviewer_refs is null
|
||||
await Project.updateOne(
|
||||
{ _id: projectId, pendingReviewer_refs: { $type: 'null' } },
|
||||
{ $set: { pendingReviewer_refs: [] } }
|
||||
).exec()
|
||||
|
||||
// Deal with the old type of boolean value for archived
|
||||
// In order to clear it
|
||||
if (typeof project.archived === 'boolean') {
|
||||
|
||||
@@ -100,6 +100,18 @@ describe('CollaboratorsHandler', function () {
|
||||
})
|
||||
|
||||
it('should remove the user from mongo', async function () {
|
||||
this.ProjectMock.expects('updateOne')
|
||||
.withArgs(
|
||||
{
|
||||
_id: this.project._id,
|
||||
pendingReviewer_refs: { $type: 'null' },
|
||||
},
|
||||
{
|
||||
$set: { pendingReviewer_refs: [] },
|
||||
}
|
||||
)
|
||||
.chain('exec')
|
||||
.resolves()
|
||||
this.ProjectMock.expects('updateOne')
|
||||
.withArgs(
|
||||
{
|
||||
@@ -142,6 +154,18 @@ describe('CollaboratorsHandler', function () {
|
||||
})
|
||||
|
||||
it('should remove the user from mongo', async function () {
|
||||
this.ProjectMock.expects('updateOne')
|
||||
.withArgs(
|
||||
{
|
||||
_id: this.oldArchivedProject._id,
|
||||
pendingReviewer_refs: { $type: 'null' },
|
||||
},
|
||||
{
|
||||
$set: { pendingReviewer_refs: [] },
|
||||
}
|
||||
)
|
||||
.chain('exec')
|
||||
.resolves()
|
||||
this.ProjectMock.expects('updateOne')
|
||||
.withArgs(
|
||||
{
|
||||
@@ -182,6 +206,18 @@ describe('CollaboratorsHandler', function () {
|
||||
})
|
||||
|
||||
it('should remove the user from mongo', async function () {
|
||||
this.ProjectMock.expects('updateOne')
|
||||
.withArgs(
|
||||
{
|
||||
_id: this.archivedProject._id,
|
||||
pendingReviewer_refs: { $type: 'null' },
|
||||
},
|
||||
{
|
||||
$set: { pendingReviewer_refs: [] },
|
||||
}
|
||||
)
|
||||
.chain('exec')
|
||||
.resolves()
|
||||
this.ProjectMock.expects('updateOne')
|
||||
.withArgs(
|
||||
{
|
||||
@@ -469,6 +505,18 @@ describe('CollaboratorsHandler', function () {
|
||||
.chain('exec')
|
||||
.resolves({ _id: projectId })
|
||||
|
||||
this.ProjectMock.expects('updateOne')
|
||||
.withArgs(
|
||||
{
|
||||
_id: projectId,
|
||||
pendingReviewer_refs: { $type: 'null' },
|
||||
},
|
||||
{
|
||||
$set: { pendingReviewer_refs: [] },
|
||||
}
|
||||
)
|
||||
.chain('exec')
|
||||
.resolves()
|
||||
this.ProjectMock.expects('updateOne')
|
||||
.withArgs(
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user