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) {
|
expectRestored(callback) {
|
||||||
DeletedSubscriptionModel.findOne(
|
DeletedSubscriptionModel.findOne({
|
||||||
{ 'subscription._id': this.subscription._id },
|
'subscription._id': this.subscription._id,
|
||||||
(error, deletedSubscription) => {
|
})
|
||||||
if (error) {
|
.then(deletedSubscription => {
|
||||||
return callback(error)
|
|
||||||
}
|
|
||||||
expect(deletedSubscription).to.be.null
|
expect(deletedSubscription).to.be.null
|
||||||
SubscriptionModel.findById(
|
SubscriptionModel.findById(this.subscription._id)
|
||||||
this.subscription._id,
|
.then(subscription => {
|
||||||
(error, subscription) => {
|
|
||||||
expect(subscription).to.exist
|
expect(subscription).to.exist
|
||||||
expect(subscription._id.toString()).to.equal(
|
expect(subscription._id.toString()).to.equal(
|
||||||
this.subscription._id.toString()
|
this.subscription._id.toString()
|
||||||
|
@ -38,11 +35,11 @@ class DeletedSubscription {
|
||||||
expect(subscription.admin_id.toString()).to.equal(
|
expect(subscription.admin_id.toString()).to.equal(
|
||||||
this.subscription.admin_id.toString()
|
this.subscription.admin_id.toString()
|
||||||
)
|
)
|
||||||
callback(error)
|
callback()
|
||||||
}
|
})
|
||||||
)
|
.catch(callback)
|
||||||
}
|
})
|
||||||
)
|
.catch(callback)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,23 +15,21 @@ class Institution {
|
||||||
ensureExists(callback) {
|
ensureExists(callback) {
|
||||||
const filter = { v1Id: this.v1Id }
|
const filter = { v1Id: this.v1Id }
|
||||||
const options = { upsert: true, new: true, setDefaultsOnInsert: true }
|
const options = { upsert: true, new: true, setDefaultsOnInsert: true }
|
||||||
InstitutionModel.findOneAndUpdate(
|
InstitutionModel.findOneAndUpdate(filter, {}, options)
|
||||||
filter,
|
.then(institution => {
|
||||||
{},
|
|
||||||
options,
|
|
||||||
(error, institution) => {
|
|
||||||
this._id = institution._id
|
this._id = institution._id
|
||||||
callback(error)
|
callback()
|
||||||
}
|
})
|
||||||
)
|
.catch(callback)
|
||||||
}
|
}
|
||||||
|
|
||||||
setManagerIds(managerIds, callback) {
|
setManagerIds(managerIds, callback) {
|
||||||
return InstitutionModel.findOneAndUpdate(
|
return InstitutionModel.findOneAndUpdate(
|
||||||
{ _id: new ObjectId(this._id) },
|
{ _id: new ObjectId(this._id) },
|
||||||
{ managerIds },
|
{ managerIds }
|
||||||
callback
|
|
||||||
)
|
)
|
||||||
|
.then((...args) => callback(null, ...args))
|
||||||
|
.catch(callback)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -423,16 +423,13 @@ class User {
|
||||||
UserModel.findOneAndUpdate(
|
UserModel.findOneAndUpdate(
|
||||||
filter,
|
filter,
|
||||||
{ $set: { hashedPassword, emails: this.emails } },
|
{ $set: { hashedPassword, emails: this.emails } },
|
||||||
options,
|
options
|
||||||
(error, user) => {
|
)
|
||||||
if (error != null) {
|
.then(user => {
|
||||||
return callback(error)
|
|
||||||
}
|
|
||||||
|
|
||||||
this.setExtraAttributes(user)
|
this.setExtraAttributes(user)
|
||||||
callback(null, this.password)
|
callback(null, this.password)
|
||||||
}
|
})
|
||||||
)
|
.catch(callback)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -443,28 +440,34 @@ class User {
|
||||||
const value = features[key]
|
const value = features[key]
|
||||||
update[`features.${key}`] = value
|
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) {
|
setFeaturesOverride(featuresOverride, callback) {
|
||||||
const update = { $push: { featuresOverrides: featuresOverride } }
|
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) {
|
setOverleafId(overleafId, callback) {
|
||||||
UserModel.updateOne(
|
UserModel.updateOne({ _id: this.id }, { 'overleaf.id': overleafId })
|
||||||
{ _id: this.id },
|
.then((...args) => callback(null, ...args))
|
||||||
{ 'overleaf.id': overleafId },
|
.catch(callback)
|
||||||
callback
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setEmails(emails, 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) {
|
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) {
|
logout(callback) {
|
||||||
|
@ -1215,9 +1218,10 @@ class User {
|
||||||
overleaf: {
|
overleaf: {
|
||||||
id: v1Id,
|
id: v1Id,
|
||||||
},
|
},
|
||||||
},
|
}
|
||||||
callback
|
|
||||||
)
|
)
|
||||||
|
.then((...args) => callback(null, ...args))
|
||||||
|
.catch(callback)
|
||||||
}
|
}
|
||||||
|
|
||||||
setCollaboratorInfo(projectId, userId, info, callback) {
|
setCollaboratorInfo(projectId, userId, info, callback) {
|
||||||
|
|
Loading…
Reference in a new issue