mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Handle Mongoose callback api removal in test helpers
GitOrigin-RevId: 00b8128aed7727e7a1b6f8d2d92a5fbc3a7775fb
This commit is contained in:
parent
5cd5c1bffc
commit
330868ff0c
3 changed files with 42 additions and 43 deletions
|
@ -21,16 +21,13 @@ class DeletedSubscription {
|
|||
}
|
||||
|
||||
expectRestored(callback) {
|
||||
DeletedSubscriptionModel.findOne(
|
||||
{ 'subscription._id': this.subscription._id },
|
||||
(error, deletedSubscription) => {
|
||||
if (error) {
|
||||
return callback(error)
|
||||
}
|
||||
DeletedSubscriptionModel.findOne({
|
||||
'subscription._id': this.subscription._id,
|
||||
})
|
||||
.then(deletedSubscription => {
|
||||
expect(deletedSubscription).to.be.null
|
||||
SubscriptionModel.findById(
|
||||
this.subscription._id,
|
||||
(error, subscription) => {
|
||||
SubscriptionModel.findById(this.subscription._id)
|
||||
.then(subscription => {
|
||||
expect(subscription).to.exist
|
||||
expect(subscription._id.toString()).to.equal(
|
||||
this.subscription._id.toString()
|
||||
|
@ -38,11 +35,11 @@ class DeletedSubscription {
|
|||
expect(subscription.admin_id.toString()).to.equal(
|
||||
this.subscription.admin_id.toString()
|
||||
)
|
||||
callback(error)
|
||||
}
|
||||
)
|
||||
}
|
||||
)
|
||||
callback()
|
||||
})
|
||||
.catch(callback)
|
||||
})
|
||||
.catch(callback)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,23 +15,21 @@ class Institution {
|
|||
ensureExists(callback) {
|
||||
const filter = { v1Id: this.v1Id }
|
||||
const options = { upsert: true, new: true, setDefaultsOnInsert: true }
|
||||
InstitutionModel.findOneAndUpdate(
|
||||
filter,
|
||||
{},
|
||||
options,
|
||||
(error, institution) => {
|
||||
InstitutionModel.findOneAndUpdate(filter, {}, options)
|
||||
.then(institution => {
|
||||
this._id = institution._id
|
||||
callback(error)
|
||||
}
|
||||
)
|
||||
callback()
|
||||
})
|
||||
.catch(callback)
|
||||
}
|
||||
|
||||
setManagerIds(managerIds, callback) {
|
||||
return InstitutionModel.findOneAndUpdate(
|
||||
{ _id: new ObjectId(this._id) },
|
||||
{ managerIds },
|
||||
callback
|
||||
{ managerIds }
|
||||
)
|
||||
.then((...args) => callback(null, ...args))
|
||||
.catch(callback)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -423,16 +423,13 @@ class User {
|
|||
UserModel.findOneAndUpdate(
|
||||
filter,
|
||||
{ $set: { hashedPassword, emails: this.emails } },
|
||||
options,
|
||||
(error, user) => {
|
||||
if (error != null) {
|
||||
return callback(error)
|
||||
}
|
||||
|
||||
options
|
||||
)
|
||||
.then(user => {
|
||||
this.setExtraAttributes(user)
|
||||
callback(null, this.password)
|
||||
}
|
||||
)
|
||||
})
|
||||
.catch(callback)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
@ -443,28 +440,34 @@ class User {
|
|||
const value = features[key]
|
||||
update[`features.${key}`] = value
|
||||
}
|
||||
UserModel.updateOne({ _id: this.id }, update, callback)
|
||||
UserModel.updateOne({ _id: this.id }, update)
|
||||
.then((...args) => callback(null, ...args))
|
||||
.catch(callback)
|
||||
}
|
||||
|
||||
setFeaturesOverride(featuresOverride, callback) {
|
||||
const update = { $push: { featuresOverrides: featuresOverride } }
|
||||
UserModel.updateOne({ _id: this.id }, update, callback)
|
||||
UserModel.updateOne({ _id: this.id }, update)
|
||||
.then((...args) => callback(null, ...args))
|
||||
.catch(callback)
|
||||
}
|
||||
|
||||
setOverleafId(overleafId, callback) {
|
||||
UserModel.updateOne(
|
||||
{ _id: this.id },
|
||||
{ 'overleaf.id': overleafId },
|
||||
callback
|
||||
)
|
||||
UserModel.updateOne({ _id: this.id }, { 'overleaf.id': overleafId })
|
||||
.then((...args) => callback(null, ...args))
|
||||
.catch(callback)
|
||||
}
|
||||
|
||||
setEmails(emails, callback) {
|
||||
UserModel.updateOne({ _id: this.id }, { emails }, callback)
|
||||
UserModel.updateOne({ _id: this.id }, { emails })
|
||||
.then((...args) => callback(null, ...args))
|
||||
.catch(callback)
|
||||
}
|
||||
|
||||
setSuspended(suspended, callback) {
|
||||
UserModel.updateOne({ _id: this.id }, { suspended }, callback)
|
||||
UserModel.updateOne({ _id: this.id }, { suspended })
|
||||
.then((...args) => callback(null, ...args))
|
||||
.catch(callback)
|
||||
}
|
||||
|
||||
logout(callback) {
|
||||
|
@ -1215,9 +1218,10 @@ class User {
|
|||
overleaf: {
|
||||
id: v1Id,
|
||||
},
|
||||
},
|
||||
callback
|
||||
}
|
||||
)
|
||||
.then((...args) => callback(null, ...args))
|
||||
.catch(callback)
|
||||
}
|
||||
|
||||
setCollaboratorInfo(projectId, userId, info, callback) {
|
||||
|
|
Loading…
Reference in a new issue