Merge pull request #3298 from overleaf/jpa-re-land-mongoose-latest

[misc] re-land: remove mongojs and bump mongoose

GitOrigin-RevId: 02f78d52ffc2d373c8c0bc4860d3b2326a46f5c9
This commit is contained in:
Jakob Ackermann 2020-11-02 11:53:57 +01:00 committed by Copybot
parent a73df8203e
commit 28fe397f38
60 changed files with 453 additions and 670 deletions

View file

@ -41,7 +41,7 @@ async function removeUserFromProject(projectId, userId) {
archived = archived.filter(id => id.toString() !== userId.toString()) archived = archived.filter(id => id.toString() !== userId.toString())
await Project.update( await Project.updateOne(
{ _id: projectId }, { _id: projectId },
{ {
$set: { archived: archived }, $set: { archived: archived },
@ -55,7 +55,7 @@ async function removeUserFromProject(projectId, userId) {
} }
) )
} else { } else {
await Project.update( await Project.updateOne(
{ _id: projectId }, { _id: projectId },
{ {
$pull: { $pull: {
@ -126,7 +126,7 @@ async function addUserIdToProject(
ContactManager.addContact(addingUserId, userId) ContactManager.addContact(addingUserId, userId)
} }
await Project.update({ _id: projectId }, { $addToSet: level }).exec() await Project.updateOne({ _id: projectId }, { $addToSet: level }).exec()
// Flush to TPDS in background to add files to collaborator's Dropbox // Flush to TPDS in background to add files to collaborator's Dropbox
TpdsProjectFlusher.promises.flushProjectToTpds(projectId).catch(err => { TpdsProjectFlusher.promises.flushProjectToTpds(projectId).catch(err => {
@ -152,40 +152,35 @@ async function transferProjects(fromUserId, toUserId) {
const projectIds = projects.map(p => p._id) const projectIds = projects.map(p => p._id)
logger.log({ projectIds, fromUserId, toUserId }, 'transferring projects') logger.log({ projectIds, fromUserId, toUserId }, 'transferring projects')
await Project.update( await Project.updateMany(
{ owner_ref: fromUserId }, { owner_ref: fromUserId },
{ $set: { owner_ref: toUserId } }, { $set: { owner_ref: toUserId } }
{ multi: true }
).exec() ).exec()
await Project.update( await Project.updateMany(
{ collaberator_refs: fromUserId }, { collaberator_refs: fromUserId },
{ {
$addToSet: { collaberator_refs: toUserId } $addToSet: { collaberator_refs: toUserId }
}, }
{ multi: true }
).exec() ).exec()
await Project.update( await Project.updateMany(
{ collaberator_refs: fromUserId }, { collaberator_refs: fromUserId },
{ {
$pull: { collaberator_refs: fromUserId } $pull: { collaberator_refs: fromUserId }
}, }
{ multi: true }
).exec() ).exec()
await Project.update( await Project.updateMany(
{ readOnly_refs: fromUserId }, { readOnly_refs: fromUserId },
{ {
$addToSet: { readOnly_refs: toUserId } $addToSet: { readOnly_refs: toUserId }
}, }
{ multi: true }
).exec() ).exec()
await Project.update( await Project.updateMany(
{ readOnly_refs: fromUserId }, { readOnly_refs: fromUserId },
{ {
$pull: { readOnly_refs: fromUserId } $pull: { readOnly_refs: fromUserId }
}, }
{ multi: true }
).exec() ).exec()
// Flush in background, no need to block on this // Flush in background, no need to block on this

View file

@ -51,7 +51,7 @@ const CollaboratorsInviteHandler = {
callback = function(err, count) {} callback = function(err, count) {}
} }
logger.log({ projectId }, 'counting invites for project') logger.log({ projectId }, 'counting invites for project')
return ProjectInvite.count({ projectId }, function(err, count) { return ProjectInvite.countDocuments({ projectId }, function(err, count) {
if (err != null) { if (err != null) {
OError.tag(err, 'error getting invites from mongo', { OError.tag(err, 'error getting invites from mongo', {
projectId projectId
@ -212,7 +212,7 @@ const CollaboratorsInviteHandler = {
callback = function(err) {} callback = function(err) {}
} }
logger.log({ projectId, inviteId }, 'removing invite') logger.log({ projectId, inviteId }, 'removing invite')
return ProjectInvite.remove({ projectId, _id: inviteId }, function(err) { return ProjectInvite.deleteOne({ projectId, _id: inviteId }, function(err) {
if (err != null) { if (err != null) {
OError.tag(err, 'error removing invite', { OError.tag(err, 'error removing invite', {
projectId, projectId,
@ -333,7 +333,7 @@ const CollaboratorsInviteHandler = {
} }
// Remove invite // Remove invite
logger.log({ projectId, inviteId }, 'removing invite') logger.log({ projectId, inviteId }, 'removing invite')
return ProjectInvite.remove({ _id: inviteId }, function(err) { return ProjectInvite.deleteOne({ _id: inviteId }, function(err) {
if (err != null) { if (err != null) {
OError.tag(err, 'error removing invite', { OError.tag(err, 'error removing invite', {
projectId, projectId,

View file

@ -83,7 +83,7 @@ async function _transferOwnership(projectId, previousOwnerId, newOwnerId) {
projectId, projectId,
newOwnerId newOwnerId
) )
await Project.update( await Project.updateOne(
{ _id: projectId }, { _id: projectId },
{ $set: { owner_ref: newOwnerId } } { $set: { owner_ref: newOwnerId } }
).exec() ).exec()

View file

@ -96,7 +96,7 @@ module.exports = ProjectCollabratecDetailsHandler = {
} }
} }
} }
return Project.update(query, update, callback) return Project.updateOne(query, update, callback)
}, },
setCollabratecUsers(project_id, collabratec_users, callback) { setCollabratecUsers(project_id, collabratec_users, callback) {
@ -122,7 +122,7 @@ module.exports = ProjectCollabratecDetailsHandler = {
} }
} }
const update = { $set: { collabratecUsers: collabratec_users } } const update = { $set: { collabratecUsers: collabratec_users } }
return Project.update({ _id: project_id }, update, callback) return Project.updateOne({ _id: project_id }, update, callback)
}, },
unlinkCollabratecUserProject(project_id, user_id, callback) { unlinkCollabratecUserProject(project_id, user_id, callback) {
@ -144,7 +144,7 @@ module.exports = ProjectCollabratecDetailsHandler = {
} }
} }
} }
return Project.update(query, update, callback) return Project.updateOne(query, update, callback)
}, },
updateCollabratecUserIds(old_user_id, new_user_id, callback) { updateCollabratecUserIds(old_user_id, new_user_id, callback) {
@ -160,7 +160,6 @@ module.exports = ProjectCollabratecDetailsHandler = {
} }
const query = { 'collabratecUsers.user_id': old_user_id } const query = { 'collabratecUsers.user_id': old_user_id }
const update = { $set: { 'collabratecUsers.$.user_id': new_user_id } } const update = { $set: { 'collabratecUsers.$.user_id': new_user_id } }
const options = { multi: true } return Project.updateMany(query, update, callback)
return Project.update(query, update, options, callback)
} }
} }

View file

@ -57,7 +57,7 @@ async function markAsDeletedByExternalSource(projectId) {
{ project_id: projectId }, { project_id: projectId },
'marking project as deleted by external data source' 'marking project as deleted by external data source'
) )
await Project.update( await Project.updateOne(
{ _id: projectId }, { _id: projectId },
{ deletedByExternalDataSource: true } { deletedByExternalDataSource: true }
).exec() ).exec()
@ -68,7 +68,7 @@ async function markAsDeletedByExternalSource(projectId) {
} }
async function unmarkAsDeletedByExternalSource(projectId) { async function unmarkAsDeletedByExternalSource(projectId) {
await Project.update( await Project.updateOne(
{ _id: projectId }, { _id: projectId },
{ deletedByExternalDataSource: false } { deletedByExternalDataSource: false }
).exec() ).exec()
@ -101,7 +101,7 @@ async function expireDeletedProjectsAfterDuration() {
} }
async function restoreProject(projectId) { async function restoreProject(projectId) {
await Project.update( await Project.updateOne(
{ _id: projectId }, { _id: projectId },
{ $unset: { archived: true } } { $unset: { archived: true } }
).exec() ).exec()
@ -119,7 +119,7 @@ async function archiveProject(projectId, userId) {
'ARCHIVE' 'ARCHIVE'
) )
await Project.update( await Project.updateOne(
{ _id: projectId }, { _id: projectId },
{ $set: { archived: archived }, $pull: { trashed: ObjectId(userId) } } { $set: { archived: archived }, $pull: { trashed: ObjectId(userId) } }
) )
@ -142,7 +142,10 @@ async function unarchiveProject(projectId, userId) {
'UNARCHIVE' 'UNARCHIVE'
) )
await Project.update({ _id: projectId }, { $set: { archived: archived } }) await Project.updateOne(
{ _id: projectId },
{ $set: { archived: archived } }
)
} catch (err) { } catch (err) {
logger.warn({ err }, 'problem unarchiving project') logger.warn({ err }, 'problem unarchiving project')
throw err throw err
@ -162,7 +165,7 @@ async function trashProject(projectId, userId) {
'UNARCHIVE' 'UNARCHIVE'
) )
await Project.update( await Project.updateOne(
{ _id: projectId }, { _id: projectId },
{ {
$addToSet: { trashed: ObjectId(userId) }, $addToSet: { trashed: ObjectId(userId) },
@ -182,7 +185,7 @@ async function untrashProject(projectId, userId) {
throw new Errors.NotFoundError('project not found') throw new Errors.NotFoundError('project not found')
} }
await Project.update( await Project.updateOne(
{ _id: projectId }, { _id: projectId },
{ $pull: { trashed: ObjectId(userId) } } { $pull: { trashed: ObjectId(userId) } }
) )
@ -227,7 +230,7 @@ async function deleteProject(projectId, options = {}) {
key => (deleterData[key] === undefined ? delete deleterData[key] : '') key => (deleterData[key] === undefined ? delete deleterData[key] : '')
) )
await DeletedProject.update( await DeletedProject.updateOne(
{ 'deleterData.deletedProjectId': projectId }, { 'deleterData.deletedProjectId': projectId },
{ project, deleterData }, { project, deleterData },
{ upsert: true } { upsert: true }
@ -251,7 +254,7 @@ async function deleteProject(projectId, options = {}) {
}) })
} }
await Project.remove({ _id: projectId }).exec() await Project.deleteOne({ _id: projectId }).exec()
} catch (err) { } catch (err) {
logger.warn({ err }, 'problem deleting project') logger.warn({ err }, 'problem deleting project')
throw err throw err
@ -316,7 +319,7 @@ async function expireDeletedProject(projectId) {
await HistoryManager.promises.deleteProject(deletedProject.project._id) await HistoryManager.promises.deleteProject(deletedProject.project._id)
await FilestoreHandler.promises.deleteProject(deletedProject.project._id) await FilestoreHandler.promises.deleteProject(deletedProject.project._id)
await DeletedProject.update( await DeletedProject.updateOne(
{ {
_id: deletedProject._id _id: deletedProject._id
}, },

View file

@ -90,7 +90,7 @@ async function setProjectDescription(projectId, description) {
'setting project description' 'setting project description'
) )
try { try {
await Project.update(conditions, update).exec() await Project.updateOne(conditions, update).exec()
} catch (err) { } catch (err) {
logger.warn({ err }, 'something went wrong setting project description') logger.warn({ err }, 'something went wrong setting project description')
throw err throw err
@ -111,7 +111,7 @@ async function renameProject(projectId, newName) {
return return
} }
const oldProjectName = project.name const oldProjectName = project.name
await Project.update({ _id: projectId }, { name: newName }).exec() await Project.updateOne({ _id: projectId }, { name: newName }).exec()
await TpdsUpdateSender.promises.moveEntity({ await TpdsUpdateSender.promises.moveEntity({
project_id: projectId, project_id: projectId,
project_name: oldProjectName, project_name: oldProjectName,
@ -197,7 +197,7 @@ async function setPublicAccessLevel(projectId, newAccessLevel) {
newAccessLevel newAccessLevel
) )
) { ) {
await Project.update( await Project.updateOne(
{ _id: projectId }, { _id: projectId },
{ publicAccesLevel: newAccessLevel } { publicAccesLevel: newAccessLevel }
).exec() ).exec()
@ -216,7 +216,7 @@ async function ensureTokensArePresent(projectId) {
return project.tokens return project.tokens
} }
await _generateTokens(project) await _generateTokens(project)
await Project.update( await Project.updateOne(
{ _id: projectId }, { _id: projectId },
{ $set: { tokens: project.tokens } } { $set: { tokens: project.tokens } }
).exec() ).exec()
@ -224,7 +224,7 @@ async function ensureTokensArePresent(projectId) {
} }
async function clearTokens(projectId) { async function clearTokens(projectId) {
await Project.update( await Project.updateOne(
{ _id: projectId }, { _id: projectId },
{ $unset: { tokens: 1 }, $set: { publicAccesLevel: 'private' } } { $unset: { tokens: 1 }, $set: { publicAccesLevel: 'private' } }
).exec() ).exec()

View file

@ -182,7 +182,7 @@ const ProjectEntityUpdateHandler = {
return callback(err) return callback(err)
} }
if (ProjectEntityUpdateHandler.isPathValidForRootDoc(docPath)) { if (ProjectEntityUpdateHandler.isPathValidForRootDoc(docPath)) {
Project.update( Project.updateOne(
{ _id: projectId }, { _id: projectId },
{ rootDoc_id: newRootDocID }, { rootDoc_id: newRootDocID },
{}, {},
@ -201,7 +201,7 @@ const ProjectEntityUpdateHandler = {
unsetRootDoc(projectId, callback) { unsetRootDoc(projectId, callback) {
logger.log({ projectId }, 'removing root doc') logger.log({ projectId }, 'removing root doc')
Project.update( Project.updateOne(
{ _id: projectId }, { _id: projectId },
{ $unset: { rootDoc_id: true } }, { $unset: { rootDoc_id: true } },
{}, {},

View file

@ -31,7 +31,7 @@ const ProjectHistoryHandler = {
return callback(new Error('invalid history id')) return callback(new Error('invalid history id'))
} }
// use $exists:false to prevent overwriting any existing history id, atomically // use $exists:false to prevent overwriting any existing history id, atomically
return Project.update( return Project.updateOne(
{ _id: project_id, 'overleaf.history.id': { $exists: false } }, { _id: project_id, 'overleaf.history.id': { $exists: false } },
{ 'overleaf.history.id': history_id }, { 'overleaf.history.id': history_id },
function(err, result) { function(err, result) {
@ -72,7 +72,7 @@ const ProjectHistoryHandler = {
if (callback == null) { if (callback == null) {
callback = function(err, result) {} callback = function(err, result) {}
} }
return Project.update( return Project.updateOne(
{ _id: project_id, 'overleaf.history.id': { $exists: true } }, { _id: project_id, 'overleaf.history.id': { $exists: true } },
{ {
'overleaf.history.display': true, 'overleaf.history.display': true,
@ -95,7 +95,7 @@ const ProjectHistoryHandler = {
if (callback == null) { if (callback == null) {
callback = function(err, result) {} callback = function(err, result) {}
} }
return Project.update( return Project.updateOne(
{ _id: project_id, 'overleaf.history.upgradedAt': { $exists: true } }, { _id: project_id, 'overleaf.history.upgradedAt': { $exists: true } },
{ {
'overleaf.history.display': false, 'overleaf.history.display': false,

View file

@ -15,7 +15,7 @@ const ProjectOptionsHandler = {
} }
const conditions = { _id: projectId } const conditions = { _id: projectId }
const update = { compiler } const update = { compiler }
Project.update(conditions, update, {}, callback) Project.updateOne(conditions, update, {}, callback)
}, },
setImageName(projectId, imageName, callback) { setImageName(projectId, imageName, callback) {
@ -31,7 +31,7 @@ const ProjectOptionsHandler = {
} }
const conditions = { _id: projectId } const conditions = { _id: projectId }
const update = { imageName: settings.imageRoot + '/' + imageName } const update = { imageName: settings.imageRoot + '/' + imageName }
Project.update(conditions, update, {}, callback) Project.updateOne(conditions, update, {}, callback)
}, },
setSpellCheckLanguage(projectId, languageCode, callback) { setSpellCheckLanguage(projectId, languageCode, callback) {
@ -46,7 +46,7 @@ const ProjectOptionsHandler = {
} }
const conditions = { _id: projectId } const conditions = { _id: projectId }
const update = { spellCheckLanguage: languageCode } const update = { spellCheckLanguage: languageCode }
Project.update(conditions, update, {}, callback) Project.updateOne(conditions, update, {}, callback)
}, },
setBrandVariationId(projectId, brandVariationId, callback) { setBrandVariationId(projectId, brandVariationId, callback) {
@ -55,13 +55,13 @@ const ProjectOptionsHandler = {
} }
const conditions = { _id: projectId } const conditions = { _id: projectId }
const update = { brandVariationId } const update = { brandVariationId }
Project.update(conditions, update, {}, callback) Project.updateOne(conditions, update, {}, callback)
}, },
unsetBrandVariationId(projectId, callback) { unsetBrandVariationId(projectId, callback) {
const conditions = { _id: projectId } const conditions = { _id: projectId }
const update = { $unset: { brandVariationId: 1 } } const update = { $unset: { brandVariationId: 1 } }
Project.update(conditions, update, {}, callback) Project.updateOne(conditions, update, {}, callback)
} }
} }

View file

@ -32,13 +32,13 @@ module.exports = {
lastUpdated: lastUpdatedAt || new Date().getTime(), lastUpdated: lastUpdatedAt || new Date().getTime(),
lastUpdatedBy lastUpdatedBy
} }
return Project.update(conditions, update, {}, callback) return Project.updateOne(conditions, update, {}, callback)
}, },
markAsOpened(project_id, callback) { markAsOpened(project_id, callback) {
const conditions = { _id: project_id } const conditions = { _id: project_id }
const update = { lastOpened: Date.now() } const update = { lastOpened: Date.now() }
return Project.update(conditions, update, {}, function(err) { return Project.updateOne(conditions, update, {}, function(err) {
if (callback != null) { if (callback != null) {
return callback() return callback()
} }
@ -48,7 +48,7 @@ module.exports = {
markAsInactive(project_id, callback) { markAsInactive(project_id, callback) {
const conditions = { _id: project_id } const conditions = { _id: project_id }
const update = { active: false } const update = { active: false }
return Project.update(conditions, update, {}, function(err) { return Project.updateOne(conditions, update, {}, function(err) {
if (callback != null) { if (callback != null) {
return callback() return callback()
} }
@ -58,7 +58,7 @@ module.exports = {
markAsActive(project_id, callback) { markAsActive(project_id, callback) {
const conditions = { _id: project_id } const conditions = { _id: project_id }
const update = { active: true } const update = { active: true }
return Project.update(conditions, update, {}, function(err) { return Project.updateOne(conditions, update, {}, function(err) {
if (callback != null) { if (callback != null) {
return callback() return callback()
} }

View file

@ -21,7 +21,7 @@ module.exports = {
} }
if (referalSource === 'bonus') { if (referalSource === 'bonus') {
User.update( User.updateOne(
query, query,
{ {
$push: { $push: {

View file

@ -38,7 +38,7 @@ const SubscriptionGroupHandler = {
}, },
replaceUserReferencesInGroups(oldId, newId, callback) { replaceUserReferencesInGroups(oldId, newId, callback) {
return Subscription.update( return Subscription.updateOne(
{ admin_id: oldId }, { admin_id: oldId },
{ admin_id: newId }, { admin_id: newId },
function(error) { function(error) {
@ -118,22 +118,12 @@ var replaceInArray = function(model, property, oldValue, newValue, callback) {
const setOldValue = {} const setOldValue = {}
setOldValue[property] = oldValue setOldValue[property] = oldValue
return model.update( model.updateMany(query, { $addToSet: setNewValue }, function(error) {
query, if (error) {
{ $addToSet: setNewValue }, return callback(error)
{ multi: true },
function(error) {
if (error != null) {
return callback(error)
}
return model.update(
query,
{ $pull: setOldValue },
{ multi: true },
callback
)
} }
) model.updateMany(query, { $pull: setOldValue }, callback)
})
} }
function __guard__(value, transform) { function __guard__(value, transform) {

View file

@ -37,7 +37,7 @@ const SubscriptionUpdater = {
} else { } else {
update.$set.manager_ids = [ObjectId(adminId)] update.$set.manager_ids = [ObjectId(adminId)]
} }
Subscription.update(query, update, callback) Subscription.updateOne(query, update, callback)
}, },
syncSubscription(recurlySubscription, adminUserId, requesterData, callback) { syncSubscription(recurlySubscription, adminUserId, requesterData, callback) {
@ -99,7 +99,7 @@ const SubscriptionUpdater = {
const searchOps = { _id: subscriptionId } const searchOps = { _id: subscriptionId }
const insertOperation = { $addToSet: { member_ids: { $each: memberIds } } } const insertOperation = { $addToSet: { member_ids: { $each: memberIds } } }
Subscription.findAndModify(searchOps, insertOperation, callback) Subscription.updateOne(searchOps, insertOperation, callback)
}, },
removeUserFromGroups(filter, userId, callback) { removeUserFromGroups(filter, userId, callback) {
@ -168,7 +168,7 @@ const SubscriptionUpdater = {
), ),
cb => cb =>
// 2. remove subscription // 2. remove subscription
Subscription.remove({ _id: subscription._id }, cb), Subscription.deleteOne({ _id: subscription._id }, cb),
cb => cb =>
// 3. refresh users features // 3. refresh users features
SubscriptionUpdater._refreshUsersFeatures(subscription, cb) SubscriptionUpdater._refreshUsersFeatures(subscription, cb)

View file

@ -209,7 +209,7 @@ var removeInviteFromTeam = function(subscriptionId, email, callback) {
async.series( async.series(
[ [
cb => Subscription.update(searchConditions, removeInvite, cb), cb => Subscription.updateOne(searchConditions, removeInvite, cb),
cb => removeLegacyInvite(subscriptionId, email, cb) cb => removeLegacyInvite(subscriptionId, email, cb)
], ],
callback callback
@ -217,7 +217,7 @@ var removeInviteFromTeam = function(subscriptionId, email, callback) {
} }
var removeLegacyInvite = (subscriptionId, email, callback) => var removeLegacyInvite = (subscriptionId, email, callback) =>
Subscription.update( Subscription.updateOne(
{ {
_id: new ObjectId(subscriptionId.toString()) _id: new ObjectId(subscriptionId.toString())
}, },

View file

@ -8,7 +8,7 @@ module.exports = {
const value = features[key] const value = features[key]
update[`features.${key}`] = value update[`features.${key}`] = value
} }
User.update(conditions, update, (err, result) => User.updateOne(conditions, update, (err, result) =>
callback(err, features, (result ? result.nModified : 0) === 1) callback(err, features, (result ? result.nModified : 0) === 1)
) )
}, },
@ -16,7 +16,7 @@ module.exports = {
overrideFeatures(userId, features, callback) { overrideFeatures(userId, features, callback) {
const conditions = { _id: userId } const conditions = { _id: userId }
const update = { features } const update = { features }
User.update(conditions, update, (err, result) => User.updateOne(conditions, update, (err, result) =>
callback(err, (result ? result.nModified : 0) === 1) callback(err, (result ? result.nModified : 0) === 1)
) )
} }

View file

@ -31,7 +31,7 @@ module.exports = SystemMessageManager = {
if (callback == null) { if (callback == null) {
callback = function(error) {} callback = function(error) {}
} }
return SystemMessage.remove({}, callback) return SystemMessage.deleteMany({}, callback)
}, },
createMessage(content, callback) { createMessage(content, callback) {

View file

@ -22,7 +22,7 @@ function renameTag(userId, tagId, name, callback) {
if (!callback) { if (!callback) {
callback = function() {} callback = function() {}
} }
Tag.update( Tag.updateOne(
{ {
_id: tagId, _id: tagId,
user_id: userId user_id: userId
@ -40,7 +40,7 @@ function deleteTag(userId, tagId, callback) {
if (!callback) { if (!callback) {
callback = function() {} callback = function() {}
} }
Tag.remove( Tag.deleteOne(
{ {
_id: tagId, _id: tagId,
user_id: userId user_id: userId
@ -56,7 +56,7 @@ function updateTagUserIds(oldUserId, newUserId, callback) {
} }
const searchOps = { user_id: oldUserId } const searchOps = { user_id: oldUserId }
const updateOperation = { $set: { user_id: newUserId } } const updateOperation = { $set: { user_id: newUserId } }
Tag.update(searchOps, updateOperation, { multi: true }, callback) Tag.updateMany(searchOps, updateOperation, callback)
} }
function removeProjectFromTag(userId, tagId, projectId, callback) { function removeProjectFromTag(userId, tagId, projectId, callback) {
@ -68,7 +68,7 @@ function removeProjectFromTag(userId, tagId, projectId, callback) {
user_id: userId user_id: userId
} }
const deleteOperation = { $pull: { project_ids: projectId } } const deleteOperation = { $pull: { project_ids: projectId } }
Tag.update(searchOps, deleteOperation, callback) Tag.updateOne(searchOps, deleteOperation, callback)
} }
function addProjectToTag(userId, tagId, projectId, callback) { function addProjectToTag(userId, tagId, projectId, callback) {
@ -92,13 +92,13 @@ function addProjectToTagName(userId, name, projectId, callback) {
user_id: userId user_id: userId
} }
const insertOperation = { $addToSet: { project_ids: projectId } } const insertOperation = { $addToSet: { project_ids: projectId } }
Tag.update(searchOps, insertOperation, { upsert: true }, callback) Tag.updateOne(searchOps, insertOperation, { upsert: true }, callback)
} }
function removeProjectFromAllTags(userId, projectId, callback) { function removeProjectFromAllTags(userId, projectId, callback) {
const searchOps = { user_id: userId } const searchOps = { user_id: userId }
const deleteOperation = { $pull: { project_ids: projectId } } const deleteOperation = { $pull: { project_ids: projectId } }
Tag.update(searchOps, deleteOperation, { multi: true }, callback) Tag.updateMany(searchOps, deleteOperation, callback)
} }
const TagsHandler = { const TagsHandler = {

View file

@ -112,7 +112,7 @@ const TemplatesManager = {
fromV1TemplateId: templateId, fromV1TemplateId: templateId,
fromV1TemplateVersionId: templateVersionId fromV1TemplateVersionId: templateVersionId
} }
return Project.update( return Project.updateOne(
{ _id: project._id }, { _id: project._id },
update, update,
{}, {},

View file

@ -164,7 +164,7 @@ const TokenAccessHandler = {
addReadOnlyUserToProject(userId, projectId, callback) { addReadOnlyUserToProject(userId, projectId, callback) {
userId = ObjectId(userId.toString()) userId = ObjectId(userId.toString())
projectId = ObjectId(projectId.toString()) projectId = ObjectId(projectId.toString())
Project.update( Project.updateOne(
{ {
_id: projectId _id: projectId
}, },
@ -178,7 +178,7 @@ const TokenAccessHandler = {
addReadAndWriteUserToProject(userId, projectId, callback) { addReadAndWriteUserToProject(userId, projectId, callback) {
userId = ObjectId(userId.toString()) userId = ObjectId(userId.toString())
projectId = ObjectId(projectId.toString()) projectId = ObjectId(projectId.toString())
Project.update( Project.updateOne(
{ {
_id: projectId _id: projectId
}, },

View file

@ -258,7 +258,7 @@ async function unlinkAccounts(
} }
} }
// update v2 user // update v2 user
await User.update(query, update).exec() await User.updateOne(query, update).exec()
// update v1 affiliations record // update v1 affiliations record
await InstitutionsAPI.promises.removeEntitlement(userId, institutionEmail) await InstitutionsAPI.promises.removeEntitlement(userId, institutionEmail)
// send email // send email
@ -283,7 +283,7 @@ async function updateEntitlement(
} }
} }
// update v2 user // update v2 user
await User.update(query, update).exec() await User.updateOne(query, update).exec()
// update v1 affiliations record // update v1 affiliations record
if (hasEntitlement) { if (hasEntitlement) {
await InstitutionsAPI.promises.addEntitlement(userId, institutionEmail) await InstitutionsAPI.promises.addEntitlement(userId, institutionEmail)

View file

@ -101,7 +101,7 @@ async function ensureCanDeleteUser(user) {
} }
async function _createDeletedUser(user, options) { async function _createDeletedUser(user, options) {
await DeletedUser.update( await DeletedUser.updateOne(
{ 'deleterData.deletedUserId': user._id }, { 'deleterData.deletedUserId': user._id },
{ {
user: user, user: user,

View file

@ -65,7 +65,7 @@ const UserRegistrationHandler = {
async.series( async.series(
[ [
cb => cb =>
User.update( User.updateOne(
{ _id: user._id }, { _id: user._id },
{ $set: { holdingAccount: false } }, { $set: { holdingAccount: false } },
cb cb

View file

@ -114,7 +114,7 @@ var addUserToEntity = function(entity, attribute, user, callback) {
} }
const fieldUpdate = {} const fieldUpdate = {}
fieldUpdate[attribute] = user._id fieldUpdate[attribute] = user._id
return entity.update({ $addToSet: fieldUpdate }, callback) return entity.updateOne({ $addToSet: fieldUpdate }, callback)
} }
var removeUserFromEntity = function(entity, attribute, userId, callback) { var removeUserFromEntity = function(entity, attribute, userId, callback) {
@ -123,7 +123,7 @@ var removeUserFromEntity = function(entity, attribute, userId, callback) {
} }
const fieldUpdate = {} const fieldUpdate = {}
fieldUpdate[attribute] = userId fieldUpdate[attribute] = userId
return entity.update({ $pull: fieldUpdate }, callback) return entity.updateOne({ $pull: fieldUpdate }, callback)
} }
var buildEntityQuery = function(entityId, entityConfig, loggedInUser) { var buildEntityQuery = function(entityId, entityConfig, loggedInUser) {

View file

@ -2,8 +2,6 @@ const mongoose = require('mongoose')
const Settings = require('settings-sharelatex') const Settings = require('settings-sharelatex')
const logger = require('logger-sharelatex') const logger = require('logger-sharelatex')
const POOL_SIZE = Settings.mongo.poolSize
if ( if (
typeof global.beforeEach === 'function' && typeof global.beforeEach === 'function' &&
process.argv.join(' ').match(/unit/) process.argv.join(' ').match(/unit/)
@ -15,23 +13,21 @@ if (
const connectionPromise = mongoose.connect( const connectionPromise = mongoose.connect(
Settings.mongo.url, Settings.mongo.url,
{ Object.assign(
poolSize: POOL_SIZE, {
config: { autoIndex: false }, // mongoose specific config
useMongoClient: true, config: { autoIndex: false },
socketTimeoutMS: Settings.mongo.socketTimeoutMS, // mongoose defaults to false, native driver defaults to true
appname: 'web' useNewUrlParser: true,
} // use the equivalent `findOneAndUpdate` methods of the native driver
useFindAndModify: false
},
Settings.mongo.options
)
) )
mongoose.connection.on('connected', () => mongoose.connection.on('connected', () =>
logger.log( logger.log('mongoose default connection open')
{
url: Settings.mongo.url,
poolSize: POOL_SIZE
},
'mongoose default connection open'
)
) )
mongoose.connection.on('error', err => mongoose.connection.on('error', err =>
@ -44,7 +40,7 @@ mongoose.connection.on('disconnected', () =>
if (process.env.MONGOOSE_DEBUG) { if (process.env.MONGOOSE_DEBUG) {
mongoose.set('debug', (collectionName, method, query, doc) => mongoose.set('debug', (collectionName, method, query, doc) =>
logger.debug('mongoose debug', { collectionName, method, query, doc }) logger.debug({ collectionName, method, query, doc }, 'mongoose debug')
) )
} }
@ -55,8 +51,8 @@ mongoose.plugin(schema => {
mongoose.Promise = global.Promise mongoose.Promise = global.Promise
async function getNativeDb() { async function getNativeDb() {
const connection = await connectionPromise const mongooseInstance = await connectionPromise
return connection.db return mongooseInstance.connection.db
} }
mongoose.getNativeDb = getNativeDb mongoose.getNativeDb = getNativeDb

View file

@ -1,29 +0,0 @@
/* eslint-disable
max-len,
*/
// TODO: This file was created by bulk-decaffeinate.
// Fix any style issues and re-enable lint.
const Settings = require('settings-sharelatex')
const mongojs = require('mongojs')
if (
typeof global.beforeEach === 'function' &&
process.argv.join(' ').match(/unit/)
) {
throw new Error(
'It looks like unit tests are running, but you are connecting to Mongo. Missing a stub?'
)
}
const db = mongojs(Settings.mongo.url, [
'projects',
'users',
'tokens',
'docSnapshots',
'projectHistoryFailures',
'deletedProjects'
])
module.exports = {
db,
ObjectId: mongojs.ObjectId
}

View file

@ -10,7 +10,15 @@ const SubscriptionSchema = new Schema({
ref: 'User', ref: 'User',
index: { unique: true, dropDups: true } index: { unique: true, dropDups: true }
}, },
manager_ids: { type: [ObjectId], ref: 'User', required: true }, manager_ids: {
type: [ObjectId],
ref: 'User',
required: true,
validate: function(managers) {
// require at least one manager
return !!managers.length
}
},
member_ids: [{ type: ObjectId, ref: 'User' }], member_ids: [{ type: ObjectId, ref: 'User' }],
invited_emails: [String], invited_emails: [String],
teamInvites: [TeamInviteSchema], teamInvites: [TeamInviteSchema],
@ -32,11 +40,6 @@ const SubscriptionSchema = new Schema({
} }
}) })
SubscriptionSchema.statics.findAndModify = function(query, update, callback) {
const self = this
return this.update(query, update, () => self.findOne(query, callback))
}
// Subscriptions have no v1 data to fetch // Subscriptions have no v1 data to fetch
SubscriptionSchema.method('fetchV1Data', function(callback) { SubscriptionSchema.method('fetchV1Data', function(callback) {
callback(null, this) callback(null, this)

View file

@ -42,14 +42,13 @@ module.exports = settings =
# --------- # ---------
mongo: mongo:
options: { options: {
appname: 'web'
useUnifiedTopology: (process.env['MONGO_USE_UNIFIED_TOPOLOGY'] || 'true') == 'true', useUnifiedTopology: (process.env['MONGO_USE_UNIFIED_TOPOLOGY'] || 'true') == 'true',
poolSize: parseInt(process.env['MONGO_POOL_SIZE'], 10) || 10, poolSize: parseInt(process.env['MONGO_POOL_SIZE'], 10) || 10,
serverSelectionTimeoutMS: parseInt(process.env['MONGO_SERVER_SELECTION_TIMEOUT'], 10) || 60000, serverSelectionTimeoutMS: parseInt(process.env['MONGO_SERVER_SELECTION_TIMEOUT'], 10) || 60000,
socketTimeoutMS: parseInt(process.env['MONGO_SOCKET_TIMEOUT'], 10) || 30000, socketTimeoutMS: parseInt(process.env['MONGO_SOCKET_TIMEOUT'], 10) || 30000,
}, },
url : process.env['MONGO_CONNECTION_STRING'] || process.env['MONGO_URL'] || "mongodb://#{process.env['MONGO_HOST'] or '127.0.0.1'}/sharelatex" url : process.env['MONGO_CONNECTION_STRING'] || process.env['MONGO_URL'] || "mongodb://#{process.env['MONGO_HOST'] or '127.0.0.1'}/sharelatex"
poolSize: parseInt(process.env['MONGO_POOL_SIZE'], 10) || 10
socketTimeoutMS: parseInt(process.env['MONGO_SOCKET_TIMEOUT'], 10) || 30000
redis: redis:
web: web:

View file

@ -168,7 +168,7 @@ module.exports = LaunchpadController = {
return next(err) return next(err)
} }
return User.update( return User.updateOne(
{ _id: user._id }, { _id: user._id },
{ {
$set: { isAdmin: true }, $set: { isAdmin: true },
@ -225,7 +225,7 @@ module.exports = LaunchpadController = {
} }
logger.log({ user_id: user._id }, 'making user an admin') logger.log({ user_id: user._id }, 'making user an admin')
User.update( User.updateOne(
{ _id: user._id }, { _id: user._id },
{ {
$set: { $set: {

View file

@ -337,7 +337,7 @@ describe('LaunchpadController', function() {
this.UserRegistrationHandler.registerNewUser = sinon this.UserRegistrationHandler.registerNewUser = sinon
.stub() .stub()
.callsArgWith(1, null, this.user) .callsArgWith(1, null, this.user)
this.User.update = sinon.stub().callsArgWith(2, null) this.User.updateOne = sinon.stub().callsArgWith(2, null)
this.AuthenticationController.setRedirectInSession = sinon.stub() this.AuthenticationController.setRedirectInSession = sinon.stub()
this.res.json = sinon.stub() this.res.json = sinon.stub()
this.next = sinon.stub() this.next = sinon.stub()
@ -365,8 +365,8 @@ describe('LaunchpadController', function() {
}) })
it('should have updated the user to make them an admin', function() { it('should have updated the user to make them an admin', function() {
this.User.update.callCount.should.equal(1) this.User.updateOne.callCount.should.equal(1)
return this.User.update return this.User.updateOne
.calledWithMatch( .calledWithMatch(
{ _id: this.user._id }, { _id: this.user._id },
{ {
@ -401,7 +401,7 @@ describe('LaunchpadController', function() {
email: this.email email: this.email
} }
this.UserRegistrationHandler.registerNewUser = sinon.stub() this.UserRegistrationHandler.registerNewUser = sinon.stub()
this.User.update = sinon.stub() this.User.updateOne = sinon.stub()
this.AuthenticationController.setRedirectInSession = sinon.stub() this.AuthenticationController.setRedirectInSession = sinon.stub()
this.res.sendStatus = sinon.stub() this.res.sendStatus = sinon.stub()
this.next = sinon.stub() this.next = sinon.stub()
@ -440,7 +440,7 @@ describe('LaunchpadController', function() {
email: this.email email: this.email
} }
this.UserRegistrationHandler.registerNewUser = sinon.stub() this.UserRegistrationHandler.registerNewUser = sinon.stub()
this.User.update = sinon.stub() this.User.updateOne = sinon.stub()
this.AuthenticationController.setRedirectInSession = sinon.stub() this.AuthenticationController.setRedirectInSession = sinon.stub()
this.res.sendStatus = sinon.stub() this.res.sendStatus = sinon.stub()
this.next = sinon.stub() this.next = sinon.stub()
@ -479,7 +479,7 @@ describe('LaunchpadController', function() {
email: this.email email: this.email
} }
this.UserRegistrationHandler.registerNewUser = sinon.stub() this.UserRegistrationHandler.registerNewUser = sinon.stub()
this.User.update = sinon.stub() this.User.updateOne = sinon.stub()
this.AuthenticationController.setRedirectInSession = sinon.stub() this.AuthenticationController.setRedirectInSession = sinon.stub()
this.res.sendStatus = sinon.stub() this.res.sendStatus = sinon.stub()
this.next = sinon.stub() this.next = sinon.stub()
@ -514,7 +514,7 @@ describe('LaunchpadController', function() {
email: this.email email: this.email
} }
this.UserRegistrationHandler.registerNewUser = sinon.stub() this.UserRegistrationHandler.registerNewUser = sinon.stub()
this.User.update = sinon.stub() this.User.updateOne = sinon.stub()
this.AuthenticationController.setRedirectInSession = sinon.stub() this.AuthenticationController.setRedirectInSession = sinon.stub()
this.res.sendStatus = sinon.stub() this.res.sendStatus = sinon.stub()
this.next = sinon.stub() this.next = sinon.stub()
@ -555,7 +555,7 @@ describe('LaunchpadController', function() {
this.UserRegistrationHandler.registerNewUser = sinon this.UserRegistrationHandler.registerNewUser = sinon
.stub() .stub()
.callsArgWith(1, new Error('woops')) .callsArgWith(1, new Error('woops'))
this.User.update = sinon.stub() this.User.updateOne = sinon.stub()
this.AuthenticationController.setRedirectInSession = sinon.stub() this.AuthenticationController.setRedirectInSession = sinon.stub()
this.res.json = sinon.stub() this.res.json = sinon.stub()
this.next = sinon.stub() this.next = sinon.stub()
@ -583,7 +583,7 @@ describe('LaunchpadController', function() {
}) })
it('should not call update', function() { it('should not call update', function() {
return this.User.update.callCount.should.equal(0) return this.User.updateOne.callCount.should.equal(0)
}) })
}) })
@ -601,7 +601,7 @@ describe('LaunchpadController', function() {
this.UserRegistrationHandler.registerNewUser = sinon this.UserRegistrationHandler.registerNewUser = sinon
.stub() .stub()
.callsArgWith(1, null, this.user) .callsArgWith(1, null, this.user)
this.User.update = sinon.stub().callsArgWith(2, new Error('woops')) this.User.updateOne = sinon.stub().callsArgWith(2, new Error('woops'))
this.AuthenticationController.setRedirectInSession = sinon.stub() this.AuthenticationController.setRedirectInSession = sinon.stub()
this.res.json = sinon.stub() this.res.json = sinon.stub()
this.next = sinon.stub() this.next = sinon.stub()
@ -645,7 +645,7 @@ describe('LaunchpadController', function() {
this.UserRegistrationHandler.registerNewUser = sinon this.UserRegistrationHandler.registerNewUser = sinon
.stub() .stub()
.callsArgWith(1, null, this.user) .callsArgWith(1, null, this.user)
this.User.update = sinon.stub().callsArgWith(2, null) this.User.updateOne = sinon.stub().callsArgWith(2, null)
this.AuthenticationController.setRedirectInSession = sinon.stub() this.AuthenticationController.setRedirectInSession = sinon.stub()
this.UserGetter.getUser = sinon this.UserGetter.getUser = sinon
.stub() .stub()
@ -676,7 +676,7 @@ describe('LaunchpadController', function() {
}) })
it('should have updated the user to make them an admin', function() { it('should have updated the user to make them an admin', function() {
return this.User.update return this.User.updateOne
.calledWith( .calledWith(
{ _id: this.user._id }, { _id: this.user._id },
{ {
@ -725,7 +725,7 @@ describe('LaunchpadController', function() {
this.UserRegistrationHandler.registerNewUser = sinon this.UserRegistrationHandler.registerNewUser = sinon
.stub() .stub()
.callsArgWith(1, null, this.user) .callsArgWith(1, null, this.user)
this.User.update = sinon.stub().callsArgWith(2, null) this.User.updateOne = sinon.stub().callsArgWith(2, null)
this.AuthenticationController.setRedirectInSession = sinon.stub() this.AuthenticationController.setRedirectInSession = sinon.stub()
this.res.json = sinon.stub() this.res.json = sinon.stub()
this.next = sinon.stub() this.next = sinon.stub()
@ -758,8 +758,8 @@ describe('LaunchpadController', function() {
}) })
it('should have updated the user to make them an admin', function() { it('should have updated the user to make them an admin', function() {
this.User.update.callCount.should.equal(1) this.User.updateOne.callCount.should.equal(1)
return this.User.update return this.User.updateOne
.calledWith( .calledWith(
{ _id: this.user._id }, { _id: this.user._id },
{ {
@ -790,7 +790,7 @@ describe('LaunchpadController', function() {
email: this.email email: this.email
} }
this.UserRegistrationHandler.registerNewUser = sinon.stub() this.UserRegistrationHandler.registerNewUser = sinon.stub()
this.User.update = sinon.stub() this.User.updateOne = sinon.stub()
this.AuthenticationController.setRedirectInSession = sinon.stub() this.AuthenticationController.setRedirectInSession = sinon.stub()
this.res.sendStatus = sinon.stub() this.res.sendStatus = sinon.stub()
this.next = sinon.stub() this.next = sinon.stub()
@ -825,7 +825,7 @@ describe('LaunchpadController', function() {
email: this.email email: this.email
} }
this.UserRegistrationHandler.registerNewUser = sinon.stub() this.UserRegistrationHandler.registerNewUser = sinon.stub()
this.User.update = sinon.stub() this.User.updateOne = sinon.stub()
this.AuthenticationController.setRedirectInSession = sinon.stub() this.AuthenticationController.setRedirectInSession = sinon.stub()
this.res.sendStatus = sinon.stub() this.res.sendStatus = sinon.stub()
this.next = sinon.stub() this.next = sinon.stub()
@ -862,7 +862,7 @@ describe('LaunchpadController', function() {
email: this.email email: this.email
} }
this.UserRegistrationHandler.registerNewUser = sinon.stub() this.UserRegistrationHandler.registerNewUser = sinon.stub()
this.User.update = sinon.stub() this.User.updateOne = sinon.stub()
this.AuthenticationController.setRedirectInSession = sinon.stub() this.AuthenticationController.setRedirectInSession = sinon.stub()
this.res.sendStatus = sinon.stub() this.res.sendStatus = sinon.stub()
this.next = sinon.stub() this.next = sinon.stub()
@ -895,7 +895,7 @@ describe('LaunchpadController', function() {
email: this.email email: this.email
} }
this.UserRegistrationHandler.registerNewUser = sinon.stub() this.UserRegistrationHandler.registerNewUser = sinon.stub()
this.User.update = sinon.stub() this.User.updateOne = sinon.stub()
this.AuthenticationController.setRedirectInSession = sinon.stub() this.AuthenticationController.setRedirectInSession = sinon.stub()
this.res.sendStatus = sinon.stub() this.res.sendStatus = sinon.stub()
this.next = sinon.stub() this.next = sinon.stub()
@ -934,7 +934,7 @@ describe('LaunchpadController', function() {
this.UserRegistrationHandler.registerNewUser = sinon this.UserRegistrationHandler.registerNewUser = sinon
.stub() .stub()
.callsArgWith(1, new Error('woops')) .callsArgWith(1, new Error('woops'))
this.User.update = sinon.stub() this.User.updateOne = sinon.stub()
this.AuthenticationController.setRedirectInSession = sinon.stub() this.AuthenticationController.setRedirectInSession = sinon.stub()
this.res.json = sinon.stub() this.res.json = sinon.stub()
this.next = sinon.stub() this.next = sinon.stub()
@ -967,7 +967,7 @@ describe('LaunchpadController', function() {
}) })
it('should not call update', function() { it('should not call update', function() {
return this.User.update.callCount.should.equal(0) return this.User.updateOne.callCount.should.equal(0)
}) })
}) })
@ -983,7 +983,7 @@ describe('LaunchpadController', function() {
this.UserRegistrationHandler.registerNewUser = sinon this.UserRegistrationHandler.registerNewUser = sinon
.stub() .stub()
.callsArgWith(1, null, this.user) .callsArgWith(1, null, this.user)
this.User.update = sinon.stub().callsArgWith(2, new Error('woops')) this.User.updateOne = sinon.stub().callsArgWith(2, new Error('woops'))
this.AuthenticationController.setRedirectInSession = sinon.stub() this.AuthenticationController.setRedirectInSession = sinon.stub()
this.res.json = sinon.stub() this.res.json = sinon.stub()
this.next = sinon.stub() this.next = sinon.stub()

View file

@ -12051,9 +12051,9 @@
} }
}, },
"bson": { "bson": {
"version": "1.0.4", "version": "1.1.5",
"resolved": "https://registry.npmjs.org/bson/-/bson-1.0.4.tgz", "resolved": "https://registry.npmjs.org/bson/-/bson-1.1.5.tgz",
"integrity": "sha512-0Ib4Zy4vANsueMULLnoYfaVNK0xOFZ+ZQ3IpQbZRMjf1fXh5ASVtjnETbyAgkKet0PYnZibw6drFX1D20sg9lw==" "integrity": "sha512-kDuEzldR21lHciPQAIulLs1LZlCXdLziXI6Mb/TDkwXhb//UORJNPXgcRs2CuO4H0DcMkpfT3/ySsP3unoZjBg=="
}, },
"buffer": { "buffer": {
"version": "4.9.1", "version": "4.9.1",
@ -12112,11 +12112,6 @@
"integrity": "sha512-4/rOEg86jivtPTeOUUT61jJO1Ya1TrR/OkqCSZDyq84WJh3LuuiphBYJN+fm5xufIk4XAFcEwte/8WzC8If/1g==", "integrity": "sha512-4/rOEg86jivtPTeOUUT61jJO1Ya1TrR/OkqCSZDyq84WJh3LuuiphBYJN+fm5xufIk4XAFcEwte/8WzC8If/1g==",
"dev": true "dev": true
}, },
"buffer-shims": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/buffer-shims/-/buffer-shims-1.0.0.tgz",
"integrity": "sha512-Zy8ZXMyxIT6RMTeY7OP/bDndfj6bwCan7SS98CEndS6deHwWPpseeHlwarNcBim+etXnF9HBc1non5JgDaJU1g=="
},
"buffer-xor": { "buffer-xor": {
"version": "1.0.3", "version": "1.0.3",
"resolved": "https://registry.npmjs.org/buffer-xor/-/buffer-xor-1.0.3.tgz", "resolved": "https://registry.npmjs.org/buffer-xor/-/buffer-xor-1.0.3.tgz",
@ -14432,7 +14427,7 @@
"d64": { "d64": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/d64/-/d64-1.0.0.tgz", "resolved": "https://registry.npmjs.org/d64/-/d64-1.0.0.tgz",
"integrity": "sha1-QAKofoUMv8n52XBrYPymE6MzbpA=" "integrity": "sha512-5eNy3WZziVYnrogqgXhcdEmqcDB2IHurTqLcrgssJsfkMVCUoUaZpK6cJjxxvLV2dUm5SuJMNcYfVGoin9UIRw=="
}, },
"damerau-levenshtein": { "damerau-levenshtein": {
"version": "1.0.6", "version": "1.0.6",
@ -15189,11 +15184,6 @@
} }
} }
}, },
"each-series": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/each-series/-/each-series-1.0.0.tgz",
"integrity": "sha512-4MQloCGGCmT5GJZK5ibgJSvTK1c1QSrNlDvLk6fEyRxjZnXjl+NNFfzhfXpmnWh33Owc9D9klrdzCUi7yc9r4Q=="
},
"east": { "east": {
"version": "1.1.0", "version": "1.1.0",
"resolved": "https://registry.npmjs.org/east/-/east-1.1.0.tgz", "resolved": "https://registry.npmjs.org/east/-/east-1.1.0.tgz",
@ -19478,11 +19468,6 @@
"parse-passwd": "^1.0.0" "parse-passwd": "^1.0.0"
} }
}, },
"hooks-fixed": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/hooks-fixed/-/hooks-fixed-2.0.2.tgz",
"integrity": "sha512-YurCM4gQSetcrhwEtpQHhQ4M7Zo7poNGqY4kQGeBS6eZtOcT3tnNs01ThFa0jYBByAiYt1MjMjP/YApG0EnAvQ=="
},
"hosted-git-info": { "hosted-git-info": {
"version": "2.8.8", "version": "2.8.8",
"resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.8.tgz", "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.8.tgz",
@ -20697,7 +20682,7 @@
"is-subset": { "is-subset": {
"version": "0.1.1", "version": "0.1.1",
"resolved": "https://registry.npmjs.org/is-subset/-/is-subset-0.1.1.tgz", "resolved": "https://registry.npmjs.org/is-subset/-/is-subset-0.1.1.tgz",
"integrity": "sha1-ilkRfZMt4d4A8kX83TnOQ/HpOaY=", "integrity": "sha512-6Ybun0IkarhmEqxXCNw/C0bna6Zb/TkfUX9UbwJtK6ObwAVCxmAP308WWTHviM/zAqXk05cdhYsUsZeGQh99iw==",
"dev": true "dev": true
}, },
"is-svg": { "is-svg": {
@ -21605,9 +21590,9 @@
} }
}, },
"kareem": { "kareem": {
"version": "1.5.0", "version": "2.3.1",
"resolved": "https://registry.npmjs.org/kareem/-/kareem-1.5.0.tgz", "resolved": "https://registry.npmjs.org/kareem/-/kareem-2.3.1.tgz",
"integrity": "sha512-DFYc05y1WSs6Ar++MHYRYu7/5r5356WDaKk8tQ8m6rlXD3VLpyG6Np81U78/wWJ4b5hjFXS7HkJNYrs85VypQA==" "integrity": "sha512-l3hLhffs9zqoDe8zjmb/mAN4B8VT3L56EUvKNqLFVs9YlFA+zx7ke1DO8STAdDyYNkeSo1nKmjuvQeI12So8Xw=="
}, },
"karma": { "karma": {
"version": "5.0.4", "version": "5.0.4",
@ -22100,7 +22085,7 @@
"keycode": { "keycode": {
"version": "2.2.0", "version": "2.2.0",
"resolved": "https://registry.npmjs.org/keycode/-/keycode-2.2.0.tgz", "resolved": "https://registry.npmjs.org/keycode/-/keycode-2.2.0.tgz",
"integrity": "sha1-PQr1bce4uOXLqNCpfxByBO7CKwQ=" "integrity": "sha512-ps3I9jAdNtRpJrbBvQjpzyFbss/skHqzS+eu4RxKLaEAtFqkjZaB6TZMSivPbLxf4K7VI4SjR0P5mRCX5+Q25A=="
}, },
"killable": { "killable": {
"version": "1.0.1", "version": "1.0.1",
@ -22587,12 +22572,12 @@
"lodash.at": { "lodash.at": {
"version": "4.6.0", "version": "4.6.0",
"resolved": "https://registry.npmjs.org/lodash.at/-/lodash.at-4.6.0.tgz", "resolved": "https://registry.npmjs.org/lodash.at/-/lodash.at-4.6.0.tgz",
"integrity": "sha1-k83OZk8KGZTqM9181A4jr9EbD/g=" "integrity": "sha512-GOTh0SEp+Yosnlpjic+8cl2WM9MykorogkGA9xyIFkkObQ3H3kNZqZ+ohuq4K3FrSVo7hMcZBMataJemrxC3BA=="
}, },
"lodash.camelcase": { "lodash.camelcase": {
"version": "4.3.0", "version": "4.3.0",
"resolved": "https://registry.npmjs.org/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz", "resolved": "https://registry.npmjs.org/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz",
"integrity": "sha1-soqmKIorn8ZRA1x3EfZathkDMaY=" "integrity": "sha512-TwuEnCnxbc3rAvhf/LbG7tJUDzhqXyFnv3dtzLOPgCG/hODL7WFnsbwktkD7yUV0RrreP/l1PALq/YSg6VvjlA=="
}, },
"lodash.defaults": { "lodash.defaults": {
"version": "4.2.0", "version": "4.2.0",
@ -22612,7 +22597,7 @@
"lodash.frompairs": { "lodash.frompairs": {
"version": "4.0.1", "version": "4.0.1",
"resolved": "https://registry.npmjs.org/lodash.frompairs/-/lodash.frompairs-4.0.1.tgz", "resolved": "https://registry.npmjs.org/lodash.frompairs/-/lodash.frompairs-4.0.1.tgz",
"integrity": "sha1-vE5SB/onV8E25XNhTpZkUGsrG9I=" "integrity": "sha512-dvqe2I+cO5MzXCMhUnfYFa9MD+/760yx2aTAN1lqEcEkf896TxgrX373igVdqSJj6tQd0jnSLE1UMuKufqqxFw=="
}, },
"lodash.get": { "lodash.get": {
"version": "4.4.2", "version": "4.4.2",
@ -22622,7 +22607,7 @@
"lodash.has": { "lodash.has": {
"version": "4.5.2", "version": "4.5.2",
"resolved": "https://registry.npmjs.org/lodash.has/-/lodash.has-4.5.2.tgz", "resolved": "https://registry.npmjs.org/lodash.has/-/lodash.has-4.5.2.tgz",
"integrity": "sha1-0Z9NwQlQWMzL4rDN9O4P5Ko3yGI=" "integrity": "sha512-rnYUdIo6xRCJnQmbVFEwcxF144erlD+M3YcJUVesflU9paQaE8p+fJDcIQrlMYbxoANFL+AB9hZrzSBBk5PL+g=="
}, },
"lodash.includes": { "lodash.includes": {
"version": "4.3.0", "version": "4.3.0",
@ -22637,7 +22622,7 @@
"lodash.isequal": { "lodash.isequal": {
"version": "4.5.0", "version": "4.5.0",
"resolved": "https://registry.npmjs.org/lodash.isequal/-/lodash.isequal-4.5.0.tgz", "resolved": "https://registry.npmjs.org/lodash.isequal/-/lodash.isequal-4.5.0.tgz",
"integrity": "sha1-QVxEePK8wwEgwizhDtMib30+GOA=", "integrity": "sha512-pDo3lu8Jhfjqls6GkMgpahsF9kCyayhgykjyLMNFTKWrpVdAQtYyB4muAMWozBB4ig/dtWAmsMxLEI8wuz+DYQ==",
"dev": true "dev": true
}, },
"lodash.isinteger": { "lodash.isinteger": {
@ -22685,7 +22670,7 @@
"lodash.sortby": { "lodash.sortby": {
"version": "4.7.0", "version": "4.7.0",
"resolved": "https://registry.npmjs.org/lodash.sortby/-/lodash.sortby-4.7.0.tgz", "resolved": "https://registry.npmjs.org/lodash.sortby/-/lodash.sortby-4.7.0.tgz",
"integrity": "sha1-7dFMgk4sycHgsKG0K7UhBRakJDg=", "integrity": "sha512-HDWXG8isMntAyRF5vZ7xKuEvOhT4AhlRt/3czTSjvGUxjYCBVRQY48ViDHyfYz9VIoBkW4TMGQNapx+l3RUwdA==",
"dev": true "dev": true
}, },
"lodash.unescape": { "lodash.unescape": {
@ -23684,7 +23669,7 @@
"minimist": { "minimist": {
"version": "0.0.8", "version": "0.0.8",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
"integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" "integrity": "sha512-miQKw5Hv4NS1Psg2517mV4e4dYNaO3++hjAvLOAzKqZ61rH8NS1SK+vbfBWZ5PY/Me/bEWhUwqMghEW5Fb9T7Q=="
} }
} }
}, },
@ -23930,171 +23915,41 @@
} }
} }
}, },
"mongodb-core": {
"version": "2.1.20",
"resolved": "https://registry.npmjs.org/mongodb-core/-/mongodb-core-2.1.20.tgz",
"integrity": "sha512-IN57CX5/Q1bhDq6ShAR6gIv4koFsZP7L8WOK1S0lR0pVDQaScffSMV5jxubLsmZ7J+UdqmykKw4r9hG3XQEGgQ==",
"requires": {
"bson": "~1.0.4",
"require_optional": "~1.0.0"
}
},
"mongojs": {
"version": "2.4.0",
"resolved": "https://registry.npmjs.org/mongojs/-/mongojs-2.4.0.tgz",
"integrity": "sha512-QqqJ06x5EBBG121dxXbm0kQ8mNVAOGMeG3RKbNvtbiFez5EhCTMDUikYcsa0V9tphlvsheO5riMHcXHxW0q3lw==",
"requires": {
"each-series": "^1.0.0",
"mongodb": "^2.0.45",
"once": "^1.3.2",
"parse-mongo-url": "^1.1.0",
"readable-stream": "^2.0.2",
"thunky": "^0.1.0",
"to-mongodb-core": "^2.0.0",
"xtend": "^4.0.0"
},
"dependencies": {
"es6-promise": {
"version": "3.2.1",
"resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-3.2.1.tgz",
"integrity": "sha1-7FYjOGgDKQkgcXDDlEjiREndH8Q="
},
"isarray": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
"integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ=="
},
"mongodb": {
"version": "2.2.36",
"resolved": "https://registry.npmjs.org/mongodb/-/mongodb-2.2.36.tgz",
"integrity": "sha512-P2SBLQ8Z0PVx71ngoXwo12+FiSfbNfGOClAao03/bant5DgLNkOPAck5IaJcEk4gKlQhDEURzfR3xuBG1/B+IA==",
"requires": {
"es6-promise": "3.2.1",
"mongodb-core": "2.1.20",
"readable-stream": "2.2.7"
},
"dependencies": {
"readable-stream": {
"version": "2.2.7",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.2.7.tgz",
"integrity": "sha1-BwV6y+JGeyIELTb5jFrVBwVOlbE=",
"requires": {
"buffer-shims": "~1.0.0",
"core-util-is": "~1.0.0",
"inherits": "~2.0.1",
"isarray": "~1.0.0",
"process-nextick-args": "~1.0.6",
"string_decoder": "~1.0.0",
"util-deprecate": "~1.0.1"
}
}
}
},
"readable-stream": {
"version": "2.3.3",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.3.tgz",
"integrity": "sha512-m+qzzcn7KUxEmd1gMbchF+Y2eIUbieUaxkWtptyHywrX0rE8QEYqPC07Vuy4Wm32/xE16NcdBctb8S0Xe/5IeQ==",
"requires": {
"core-util-is": "~1.0.0",
"inherits": "~2.0.3",
"isarray": "~1.0.0",
"process-nextick-args": "~1.0.6",
"safe-buffer": "~5.1.1",
"string_decoder": "~1.0.3",
"util-deprecate": "~1.0.1"
}
},
"string_decoder": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz",
"integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==",
"requires": {
"safe-buffer": "~5.1.0"
}
}
}
},
"mongoose": { "mongoose": {
"version": "4.13.19", "version": "5.10.9",
"resolved": "https://registry.npmjs.org/mongoose/-/mongoose-4.13.19.tgz", "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-5.10.9.tgz",
"integrity": "sha512-O41XmkbAZtLK6Uw4cqjI30s0sP8oZeG+aWweOIyE2VYHMQiYDWhVkBMtsv+Kv8chDizaBhO5oErTHexLQKzU+w==", "integrity": "sha512-7dkr1d6Uyk87hELzoc6B7Zo7kkPTx8rKummk51Y0je2V2Ttsw0KFPwTp1G8JIbBta7Wpw8j15PJi0d33Ode2nw==",
"requires": { "requires": {
"async": "2.6.0", "bson": "^1.1.4",
"bson": "~1.0.4", "kareem": "2.3.1",
"hooks-fixed": "2.0.2", "mongodb": "3.6.2",
"kareem": "1.5.0", "mongoose-legacy-pluralize": "1.0.2",
"lodash.get": "4.4.2", "mpath": "0.7.0",
"mongodb": "2.2.34", "mquery": "3.2.2",
"mpath": "0.5.1", "ms": "2.1.2",
"mpromise": "0.5.5", "regexp-clone": "1.0.0",
"mquery": "2.3.3", "safe-buffer": "5.2.1",
"ms": "2.0.0", "sift": "7.0.1",
"muri": "1.3.0",
"regexp-clone": "0.0.1",
"sliced": "1.0.1" "sliced": "1.0.1"
}, },
"dependencies": { "dependencies": {
"async": { "ms": {
"version": "2.6.0", "version": "2.1.2",
"resolved": "https://registry.npmjs.org/async/-/async-2.6.0.tgz", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
"integrity": "sha512-xAfGg1/NTLBBKlHFmnd7PlmUW9KhVQIUuSrYem9xzFUZy13ScvtyGGejaae9iAVRiRq9+Cx7DPFaAAhCpyxyPw==", "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
"requires": {
"lodash": "^4.14.0"
}
}, },
"es6-promise": { "safe-buffer": {
"version": "3.2.1", "version": "5.2.1",
"resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-3.2.1.tgz", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
"integrity": "sha1-7FYjOGgDKQkgcXDDlEjiREndH8Q=" "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ=="
},
"isarray": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
"integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE="
},
"mongodb": {
"version": "2.2.34",
"resolved": "https://registry.npmjs.org/mongodb/-/mongodb-2.2.34.tgz",
"integrity": "sha1-o09Zu+thdUrsQy3nLD/iFSakTBo=",
"requires": {
"es6-promise": "3.2.1",
"mongodb-core": "2.1.18",
"readable-stream": "2.2.7"
}
},
"mongodb-core": {
"version": "2.1.18",
"resolved": "https://registry.npmjs.org/mongodb-core/-/mongodb-core-2.1.18.tgz",
"integrity": "sha1-TEYTm986HwMt7ZHbSfOO7AFlkFA=",
"requires": {
"bson": "~1.0.4",
"require_optional": "~1.0.0"
}
},
"readable-stream": {
"version": "2.2.7",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.2.7.tgz",
"integrity": "sha1-BwV6y+JGeyIELTb5jFrVBwVOlbE=",
"requires": {
"buffer-shims": "~1.0.0",
"core-util-is": "~1.0.0",
"inherits": "~2.0.1",
"isarray": "~1.0.0",
"process-nextick-args": "~1.0.6",
"string_decoder": "~1.0.0",
"util-deprecate": "~1.0.1"
}
},
"string_decoder": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz",
"integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==",
"requires": {
"safe-buffer": "~5.1.0"
}
} }
} }
}, },
"mongoose-legacy-pluralize": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/mongoose-legacy-pluralize/-/mongoose-legacy-pluralize-1.0.2.tgz",
"integrity": "sha512-Yo/7qQU4/EyIS8YDFSeenIvXxZN+ld7YdV9LqFVQJzTLye8unujAWPZ4NWKfFA+RNjh+wvTWKY9Z3E5XM6ZZiQ=="
},
"morgan": { "morgan": {
"version": "1.10.0", "version": "1.10.0",
"resolved": "https://registry.npmjs.org/morgan/-/morgan-1.10.0.tgz", "resolved": "https://registry.npmjs.org/morgan/-/morgan-1.10.0.tgz",
@ -24148,43 +24003,39 @@
} }
}, },
"mpath": { "mpath": {
"version": "0.5.1", "version": "0.7.0",
"resolved": "https://registry.npmjs.org/mpath/-/mpath-0.5.1.tgz", "resolved": "https://registry.npmjs.org/mpath/-/mpath-0.7.0.tgz",
"integrity": "sha512-H8OVQ+QEz82sch4wbODFOz+3YQ61FYz/z3eJ5pIdbMEaUzDqA268Wd+Vt4Paw9TJfvDgVKaayC0gBzMIw2jhsg==" "integrity": "sha512-Aiq04hILxhz1L+f7sjGyn7IxYzWm1zLNNXcfhDtx04kZ2Gk7uvFdgZ8ts1cWa/6d0TQmag2yR8zSGZUmp0tFNg=="
},
"mpromise": {
"version": "0.5.5",
"resolved": "https://registry.npmjs.org/mpromise/-/mpromise-0.5.5.tgz",
"integrity": "sha512-b/IJDqWlRXIW3ZouxIkUYLZFrr4qK/oUEgfVAywuvm77nTdDmY6y57lHxA8kfLnOSM+SbAUN/VvU1RxsGBLkQw=="
}, },
"mquery": { "mquery": {
"version": "2.3.3", "version": "3.2.2",
"resolved": "https://registry.npmjs.org/mquery/-/mquery-2.3.3.tgz", "resolved": "https://registry.npmjs.org/mquery/-/mquery-3.2.2.tgz",
"integrity": "sha512-NC8L14kn+qxJbbJ1gbcEMDxF0sC3sv+1cbRReXXwVvowcwY1y9KoVZFq0ebwARibsadu8lx8nWGvm3V0Pf0ZWQ==", "integrity": "sha512-XB52992COp0KP230I3qloVUbkLUxJIu328HBP2t2EsxSFtf4W1HPSOBWOXf1bqxK4Xbb66lfMJ+Bpfd9/yZE1Q==",
"requires": { "requires": {
"bluebird": "3.5.0", "bluebird": "3.5.1",
"debug": "2.6.9", "debug": "3.1.0",
"regexp-clone": "0.0.1", "regexp-clone": "^1.0.0",
"sliced": "0.0.5" "safe-buffer": "5.1.2",
"sliced": "1.0.1"
}, },
"dependencies": { "dependencies": {
"bluebird": { "bluebird": {
"version": "3.5.0", "version": "3.5.1",
"resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.0.tgz", "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.1.tgz",
"integrity": "sha512-3LE8m8bqjGdoxfvf71yhFNrUcwy3NLy00SAo+b6MfJ8l+Bc2DzQ7mUHwX6pjK2AxfgV+YfsjCeVW3T5HLQTBsQ==" "integrity": "sha512-MKiLiV+I1AA596t9w1sQJ8jkiSr5+ZKi0WKrYGUn6d1Fx+Ij4tIj+m2WMQSGczs5jZVxV339chE8iwk6F64wjA=="
}, },
"debug": { "debug": {
"version": "2.6.9", "version": "3.1.0",
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz",
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==",
"requires": { "requires": {
"ms": "2.0.0" "ms": "2.0.0"
} }
}, },
"sliced": { "safe-buffer": {
"version": "0.0.5", "version": "5.1.2",
"resolved": "https://registry.npmjs.org/sliced/-/sliced-0.0.5.tgz", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
"integrity": "sha512-9bYT917D6H3+q8GlQBJmLVz3bc4OeVGfZ2BB12wvLnluTGfG6/8UdOUbKJDW1EEx9SZMDbjnatkau5/XcUeyOw==" "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="
} }
} }
}, },
@ -24231,11 +24082,6 @@
"integrity": "sha512-cnAsSVxIDsYt0v7HmC0hWZFwwXSh+E6PgCrREDuN/EsjgLwA5XRmlMHhSiDPrt6HxY1gTivEa/Zh7GtODoLevQ==", "integrity": "sha512-cnAsSVxIDsYt0v7HmC0hWZFwwXSh+E6PgCrREDuN/EsjgLwA5XRmlMHhSiDPrt6HxY1gTivEa/Zh7GtODoLevQ==",
"dev": true "dev": true
}, },
"muri": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/muri/-/muri-1.3.0.tgz",
"integrity": "sha512-FiaFwKl864onHFFUV/a2szAl7X0fxVlSKNdhTf+BM8i8goEgYut8u5P9MqQqIYwvaMxjzVESsoEm/2kfkFH1rg=="
},
"mute-stream": { "mute-stream": {
"version": "0.0.7", "version": "0.0.7",
"resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.7.tgz", "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.7.tgz",
@ -24245,7 +24091,7 @@
"mv": { "mv": {
"version": "2.1.1", "version": "2.1.1",
"resolved": "https://registry.npmjs.org/mv/-/mv-2.1.1.tgz", "resolved": "https://registry.npmjs.org/mv/-/mv-2.1.1.tgz",
"integrity": "sha1-rmzg1vbV4KT32JN5jQPB6pVZtqI=", "integrity": "sha512-at/ZndSy3xEGJ8i0ygALh8ru9qy7gWW1cmkaqBN29JmMlIvM//MEO9y1sk/avxuwnPcfhkejkLsuPxH81BrkSg==",
"optional": true, "optional": true,
"requires": { "requires": {
"mkdirp": "~0.5.1", "mkdirp": "~0.5.1",
@ -24256,7 +24102,7 @@
"glob": { "glob": {
"version": "6.0.4", "version": "6.0.4",
"resolved": "https://registry.npmjs.org/glob/-/glob-6.0.4.tgz", "resolved": "https://registry.npmjs.org/glob/-/glob-6.0.4.tgz",
"integrity": "sha1-DwiGD2oVUSey+t1PnOJLGqtuTSI=", "integrity": "sha512-MKZeRNyYZAVVVG1oZeLaWie1uweH40m9AZwIwxyPbTSX4hHrVYSzLg0Ro5Z5R7XKkIX+Cc6oD1rqeDJnwsB8/A==",
"optional": true, "optional": true,
"requires": { "requires": {
"inflight": "^1.0.4", "inflight": "^1.0.4",
@ -24269,7 +24115,7 @@
"rimraf": { "rimraf": {
"version": "2.4.5", "version": "2.4.5",
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.4.5.tgz", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.4.5.tgz",
"integrity": "sha1-7nEM5dk6j9uFb7Xqj/Di11k0sto=", "integrity": "sha512-J5xnxTyqaiw06JjMftq7L9ouA448dw/E7dKghkP9WpKNuwmARNNg+Gk8/u5ryb9N/Yo2+z3MCwuqFK/+qPOPfQ==",
"optional": true, "optional": true,
"requires": { "requires": {
"glob": "^6.0.1" "glob": "^6.0.1"
@ -24327,7 +24173,7 @@
"ncp": { "ncp": {
"version": "2.0.0", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/ncp/-/ncp-2.0.0.tgz", "resolved": "https://registry.npmjs.org/ncp/-/ncp-2.0.0.tgz",
"integrity": "sha1-GVoh1sRuNh0vsSgbo4uR6d9727M=", "integrity": "sha512-zIdGUrPRFTUELUvr3Gmc7KZ2Sw/h1PiVM0Af/oHB6zgnV1ikqSfRk+TOufi79aHYCW3NiOXmr1BP5nWbzojLaA==",
"optional": true "optional": true
}, },
"needle": { "needle": {
@ -26051,7 +25897,7 @@
"os-homedir": { "os-homedir": {
"version": "1.0.2", "version": "1.0.2",
"resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz",
"integrity": "sha512-B5JU3cabzk8c67mRRd3ECmROafjYMXbuzlwtqdM8IbS8ktlTix8aFGb2bAGKrSRIlnfKwovGUUr72JUPyOb6kQ==" "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M="
}, },
"os-locale": { "os-locale": {
"version": "2.1.0", "version": "2.1.0",
@ -26345,11 +26191,6 @@
"error-ex": "^1.2.0" "error-ex": "^1.2.0"
} }
}, },
"parse-mongo-url": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/parse-mongo-url/-/parse-mongo-url-1.1.1.tgz",
"integrity": "sha512-7bZUusQIrFLwvsLHBnCz2WKYQ5LKO/LwKPnvQxbMIh9gDx8H5ZsknRmLjZdn6GVdrgVOwqDrZKsY0qDLNmRgcw=="
},
"parse-ms": { "parse-ms": {
"version": "2.1.0", "version": "2.1.0",
"resolved": "https://registry.npmjs.org/parse-ms/-/parse-ms-2.1.0.tgz", "resolved": "https://registry.npmjs.org/parse-ms/-/parse-ms-2.1.0.tgz",
@ -27830,11 +27671,6 @@
"resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz",
"integrity": "sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==" "integrity": "sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A=="
}, },
"process-nextick-args": {
"version": "1.0.7",
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz",
"integrity": "sha512-yN0WQmuCX63LP/TMvAg31nvT6m4vDqJEiiv2CAZqWOGNWutc9DfDk1NPYYmKUFmaVM2UwDowH4u5AHWYP/jxKw=="
},
"progress": { "progress": {
"version": "2.0.0", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/progress/-/progress-2.0.0.tgz", "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.0.tgz",
@ -29747,7 +29583,7 @@
"react-prop-types": { "react-prop-types": {
"version": "0.4.0", "version": "0.4.0",
"resolved": "https://registry.npmjs.org/react-prop-types/-/react-prop-types-0.4.0.tgz", "resolved": "https://registry.npmjs.org/react-prop-types/-/react-prop-types-0.4.0.tgz",
"integrity": "sha1-+ZsL+0AGkpya8gUefBQUpcdbk9A=", "integrity": "sha512-IyjsJhDX9JkoOV9wlmLaS7z+oxYoIWhfzDcFy7inwoAKTu+VcVNrVpPmLeioJ94y6GeDRsnwarG1py5qofFQMg==",
"requires": { "requires": {
"warning": "^3.0.0" "warning": "^3.0.0"
} }
@ -30403,9 +30239,9 @@
} }
}, },
"regexp-clone": { "regexp-clone": {
"version": "0.0.1", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/regexp-clone/-/regexp-clone-0.0.1.tgz", "resolved": "https://registry.npmjs.org/regexp-clone/-/regexp-clone-1.0.0.tgz",
"integrity": "sha512-tfYXF0HXEYh3AtgdjqNLQ8+tmZSAKIS7KtOjmB1laJgfbsi+Lf2RVNwLZVOE3U27yBXikzQuIXglLlakvb8Thw==" "integrity": "sha512-TuAasHQNamyyJ2hb97IuBEif4qBHGjPHBS64sZwytpLEqtBQ1gPJTnOaQ6qmpET16cK14kkjbazl6+p0RRv0yw=="
}, },
"regexp.prototype.flags": { "regexp.prototype.flags": {
"version": "1.3.0", "version": "1.3.0",
@ -32356,6 +32192,11 @@
} }
} }
}, },
"sift": {
"version": "7.0.1",
"resolved": "https://registry.npmjs.org/sift/-/sift-7.0.1.tgz",
"integrity": "sha512-oqD7PMJ+uO6jV9EQCl0LrRw1OwsiPsiFQR5AR30heR+4Dl7jBBbDLnNvWiak20tzZlSE1H7RB30SX/1j/YYT7g=="
},
"signal-exit": { "signal-exit": {
"version": "3.0.2", "version": "3.0.2",
"resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz",
@ -32436,7 +32277,7 @@
"sliced": { "sliced": {
"version": "1.0.1", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/sliced/-/sliced-1.0.1.tgz", "resolved": "https://registry.npmjs.org/sliced/-/sliced-1.0.1.tgz",
"integrity": "sha512-VZBmZP8WU3sMOZm1bdgTadsQbcscK0UM8oKxKVBs4XAhUo2Xxzm/OFMGBkPusxw9xL3Uy8LrzEqGqJhclsr0yA==" "integrity": "sha1-CzpmK10Ewxd7GSa+qCsD+Dei70E="
}, },
"slugify": { "slugify": {
"version": "1.4.0", "version": "1.4.0",
@ -33853,7 +33694,7 @@
"stubs": { "stubs": {
"version": "3.0.0", "version": "3.0.0",
"resolved": "https://registry.npmjs.org/stubs/-/stubs-3.0.0.tgz", "resolved": "https://registry.npmjs.org/stubs/-/stubs-3.0.0.tgz",
"integrity": "sha1-6NK6H6nJBXAwPAMLaQD31fiavls=" "integrity": "sha512-PdHt7hHUJKxvTCgbKX9C1V/ftOcjJQgz8BZwNfV5c4B6dcGqlpelTbJ999jBGZ2jYiPAwcX5dP6oBwVlBlUbxw=="
}, },
"style-loader": { "style-loader": {
"version": "1.2.1", "version": "1.2.1",
@ -34747,11 +34588,6 @@
} }
} }
}, },
"thunky": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/thunky/-/thunky-0.1.0.tgz",
"integrity": "sha512-vquTt/sKNzFqFK8DKLg33U7deg93WKYH4CE2Ul9hOyMCfm7VXgM7GJQRpPAgnmgnrf407Fcq8TQVEKlbavAu+A=="
},
"timed-out": { "timed-out": {
"version": "4.0.1", "version": "4.0.1",
"resolved": "https://registry.npmjs.org/timed-out/-/timed-out-4.0.1.tgz", "resolved": "https://registry.npmjs.org/timed-out/-/timed-out-4.0.1.tgz",
@ -34828,15 +34664,10 @@
"resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz",
"integrity": "sha512-/OaKK0xYrs3DmxRYqL/yDc+FxFUVYhDlXMhRmv3z915w2HF1tnN1omB354j8VUGO/hbRzyD6Y3sA7v7GS/ceog==" "integrity": "sha512-/OaKK0xYrs3DmxRYqL/yDc+FxFUVYhDlXMhRmv3z915w2HF1tnN1omB354j8VUGO/hbRzyD6Y3sA7v7GS/ceog=="
}, },
"to-mongodb-core": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/to-mongodb-core/-/to-mongodb-core-2.0.0.tgz",
"integrity": "sha512-vfXXcGYFP8+0L5IPOtUzzVIvPE/G3GN0TKa/PRBlzPqYyhm+UxhPmvv634EQgO4Ot8dHbBFihOslMJQclY8Z9A=="
},
"to-no-case": { "to-no-case": {
"version": "1.0.2", "version": "1.0.2",
"resolved": "https://registry.npmjs.org/to-no-case/-/to-no-case-1.0.2.tgz", "resolved": "https://registry.npmjs.org/to-no-case/-/to-no-case-1.0.2.tgz",
"integrity": "sha1-xyKQcWTvaxeBMsjmmTAhLRtKoWo=" "integrity": "sha512-Z3g735FxuZY8rodxV4gH7LxClE4H0hTIyHNIHdk+vpQxjLm0cwnKXq/OFVZ76SOQmto7txVcwSCwkU5kqp+FKg=="
}, },
"to-object-path": { "to-object-path": {
"version": "0.3.0", "version": "0.3.0",
@ -34921,7 +34752,7 @@
"to-snake-case": { "to-snake-case": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/to-snake-case/-/to-snake-case-1.0.0.tgz", "resolved": "https://registry.npmjs.org/to-snake-case/-/to-snake-case-1.0.0.tgz",
"integrity": "sha1-znRpE4l5RgGah+Yu366upMYIq4w=", "integrity": "sha512-joRpzBAk1Bhi2eGEYBjukEWHOe/IvclOkiJl3DtA91jV6NwQ3MwXA4FHYeqk8BNp/D8bmi9tcNbRu/SozP0jbQ==",
"requires": { "requires": {
"to-space-case": "^1.0.0" "to-space-case": "^1.0.0"
} }
@ -34929,7 +34760,7 @@
"to-space-case": { "to-space-case": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/to-space-case/-/to-space-case-1.0.0.tgz", "resolved": "https://registry.npmjs.org/to-space-case/-/to-space-case-1.0.0.tgz",
"integrity": "sha1-sFLar7Gysp3HcM6gFj5ewOvJ/Bc=", "integrity": "sha512-rLdvwXZ39VOn1IxGL3V6ZstoTbwLRckQmn/U8ZDLuWwIXNpuZDhQ3AiRUlhTbOXFVE9C+dR51wM0CBDhk31VcA==",
"requires": { "requires": {
"to-no-case": "^1.0.0" "to-no-case": "^1.0.0"
} }
@ -36144,7 +35975,7 @@
"warning": { "warning": {
"version": "3.0.0", "version": "3.0.0",
"resolved": "https://registry.npmjs.org/warning/-/warning-3.0.0.tgz", "resolved": "https://registry.npmjs.org/warning/-/warning-3.0.0.tgz",
"integrity": "sha1-MuU3fLVy3kqwR1O9+IIcAe1gW3w=", "integrity": "sha512-jMBt6pUrKn5I+OGgtQ4YZLdhIeJmObddh6CsibPxyQ5yPZm1XExSyzC1LCNX7BzhxWgiHmizBWJTHJIjMjTQYQ==",
"requires": { "requires": {
"loose-envify": "^1.0.0" "loose-envify": "^1.0.0"
} }

View file

@ -98,8 +98,7 @@
"mocha": "^6.2.2", "mocha": "^6.2.2",
"moment": "^2.24.0", "moment": "^2.24.0",
"mongodb": "^3.6.0", "mongodb": "^3.6.0",
"mongojs": "2.4.0", "mongoose": "^5.10.7",
"mongoose": "^4.13.19",
"multer": "git+https://github.com/overleaf/multer.git", "multer": "git+https://github.com/overleaf/multer.git",
"nocache": "^2.1.0", "nocache": "^2.1.0",
"nodemailer": "2.1.0", "nodemailer": "2.1.0",

View file

@ -121,7 +121,7 @@ describe('FeatureUpdater.refreshFeatures', function() {
describe('when the user has bonus features', function() { describe('when the user has bonus features', function() {
beforeEach(function() { beforeEach(function() {
return User.update( return User.updateOne(
{ {
_id: this.user._id _id: this.user._id
}, },
@ -193,7 +193,7 @@ describe('FeatureUpdater.refreshFeatures', function() {
describe('when the user is due bonus features and has extra features that no longer apply', function() { describe('when the user is due bonus features and has extra features that no longer apply', function() {
beforeEach(function() { beforeEach(function() {
return User.update( return User.updateOne(
{ {
_id: this.user._id _id: this.user._id
}, },
@ -224,7 +224,7 @@ describe('FeatureUpdater.refreshFeatures', function() {
describe('when the user has a v1 plan', function() { describe('when the user has a v1 plan', function() {
beforeEach(function() { beforeEach(function() {
MockV1Api.setUser(42, { plan_name: 'free' }) MockV1Api.setUser(42, { plan_name: 'free' })
return User.update( return User.updateOne(
{ {
_id: this.user._id _id: this.user._id
}, },
@ -251,7 +251,7 @@ describe('FeatureUpdater.refreshFeatures', function() {
describe('when the user has a v1 plan and bonus features', function() { describe('when the user has a v1 plan and bonus features', function() {
beforeEach(function() { beforeEach(function() {
MockV1Api.setUser(42, { plan_name: 'free' }) MockV1Api.setUser(42, { plan_name: 'free' })
return User.update( return User.updateOne(
{ {
_id: this.user._id _id: this.user._id
}, },
@ -327,7 +327,7 @@ describe('FeatureUpdater.refreshFeatures', function() {
describe('when the notifyV1Flag is passed', function() { describe('when the notifyV1Flag is passed', function() {
beforeEach(function() { beforeEach(function() {
return User.update( return User.updateOne(
{ {
_id: this.user._id _id: this.user._id
}, },
@ -344,7 +344,7 @@ describe('FeatureUpdater.refreshFeatures', function() {
beforeEach(function() { beforeEach(function() {
const futureDate = new Date() const futureDate = new Date()
futureDate.setDate(futureDate.getDate() + 1) futureDate.setDate(futureDate.getDate() + 1)
return User.update( return User.updateOne(
{ {
_id: this.user._id _id: this.user._id
}, },

View file

@ -18,7 +18,7 @@ describe('mongoose', function() {
it('does not allow the creation of multiple users with the same email', async function() { it('does not allow the creation of multiple users with the same email', async function() {
await expect(User.create({ email: email })).to.be.fulfilled await expect(User.create({ email: email })).to.be.fulfilled
await expect(User.create({ email: email })).to.be.rejected await expect(User.create({ email: email })).to.be.rejected
await expect(User.count({ email: email })).to.eventually.equal(1) await expect(User.countDocuments({ email: email })).to.eventually.equal(1)
}) })
}) })

View file

@ -53,7 +53,7 @@ describe('Project CRUD', function() {
describe('with an array archived state', function() { describe('with an array archived state', function() {
it('should mark the project as not archived for the user', async function() { it('should mark the project as not archived for the user', async function() {
await Project.update( await Project.updateOne(
{ _id: this.projectId }, { _id: this.projectId },
{ $set: { archived: [ObjectId(this.user._id)] } } { $set: { archived: [ObjectId(this.user._id)] } }
).exec() ).exec()
@ -72,7 +72,7 @@ describe('Project CRUD', function() {
describe('with a legacy boolean state', function() { describe('with a legacy boolean state', function() {
it('should mark the project as not archived for the user', async function() { it('should mark the project as not archived for the user', async function() {
await Project.update( await Project.updateOne(
{ _id: this.projectId }, { _id: this.projectId },
{ $set: { archived: true } } { $set: { archived: true } }
).exec() ).exec()
@ -92,7 +92,7 @@ describe('Project CRUD', function() {
describe('when untrashing a project', function() { describe('when untrashing a project', function() {
it('should mark the project as untrashed for the user', async function() { it('should mark the project as untrashed for the user', async function() {
await Project.update( await Project.updateOne(
{ _id: this.projectId }, { _id: this.projectId },
{ trashed: [ObjectId(this.user._id)] } { trashed: [ObjectId(this.user._id)] }
).exec() ).exec()
@ -107,7 +107,7 @@ describe('Project CRUD', function() {
}) })
it('does nothing if the user has already untrashed the project', async function() { it('does nothing if the user has already untrashed the project', async function() {
await Project.update( await Project.updateOne(
{ _id: this.projectId }, { _id: this.projectId },
{ trashed: [ObjectId(this.user._id)] } { trashed: [ObjectId(this.user._id)] }
).exec() ).exec()

View file

@ -1107,7 +1107,7 @@ describe('ProjectStructureChanges', function() {
describe('when rootDoc_id matches doc being deleted', function() { describe('when rootDoc_id matches doc being deleted', function() {
beforeEach(function(done) { beforeEach(function(done) {
Project.update( Project.updateOne(
{ _id: this.exampleProjectId }, { _id: this.exampleProjectId },
{ $set: { rootDoc_id: this.exampleDocId } }, { $set: { rootDoc_id: this.exampleDocId } },
done done
@ -1139,7 +1139,7 @@ describe('ProjectStructureChanges', function() {
describe('when rootDoc_id does not match doc being deleted', function() { describe('when rootDoc_id does not match doc being deleted', function() {
beforeEach(function(done) { beforeEach(function(done) {
this.exampleRootDocId = new ObjectId() this.exampleRootDocId = new ObjectId()
Project.update( Project.updateOne(
{ _id: this.exampleProjectId }, { _id: this.exampleProjectId },
{ $set: { rootDoc_id: this.exampleRootDocId } }, { $set: { rootDoc_id: this.exampleRootDocId } },
done done

View file

@ -103,7 +103,7 @@ describe('Subscriptions', function() {
MockRecurlyApi.mockSubscriptions = [] MockRecurlyApi.mockSubscriptions = []
MockRecurlyApi.coupons = {} MockRecurlyApi.coupons = {}
MockRecurlyApi.redemptions = {} MockRecurlyApi.redemptions = {}
Subscription.remove( Subscription.deleteOne(
{ {
admin_id: this.user._id admin_id: this.user._id
}, },
@ -207,7 +207,7 @@ describe('Subscriptions', function() {
}) })
after(function(done) { after(function(done) {
Subscription.remove( Subscription.deleteOne(
{ {
admin_id: this.user._id admin_id: this.user._id
}, },
@ -277,7 +277,7 @@ describe('Subscriptions', function() {
}) })
after(function(done) { after(function(done) {
Subscription.remove( Subscription.deleteOne(
{ {
admin_id: this.owner1._id admin_id: this.owner1._id
}, },
@ -285,7 +285,7 @@ describe('Subscriptions', function() {
if (error != null) { if (error != null) {
return done(error) return done(error)
} }
return Subscription.remove( return Subscription.deleteOne(
{ {
admin_id: this.owner2._id admin_id: this.owner2._id
}, },
@ -349,7 +349,7 @@ describe('Subscriptions', function() {
}) })
after(function(done) { after(function(done) {
Subscription.remove( Subscription.deleteOne(
{ {
admin_id: this.owner1._id admin_id: this.owner1._id
}, },
@ -406,7 +406,7 @@ describe('Subscriptions', function() {
}) })
after(function(done) { after(function(done) {
Institution.remove( Institution.deleteOne(
{ {
v1Id: this.v1Id v1Id: this.v1Id
}, },

View file

@ -131,16 +131,20 @@ class User {
const value = features[key] const value = features[key]
update[`features.${key}`] = value update[`features.${key}`] = value
} }
UserModel.update({ _id: this.id }, update, callback) UserModel.updateOne({ _id: this.id }, update, callback)
} }
setFeaturesOverride(featuresOverride, callback) { setFeaturesOverride(featuresOverride, callback) {
const update = { $push: { featuresOverrides: featuresOverride } } const update = { $push: { featuresOverrides: featuresOverride } }
UserModel.update({ _id: this.id }, update, callback) UserModel.updateOne({ _id: this.id }, update, callback)
} }
setOverleafId(overleafId, callback) { setOverleafId(overleafId, callback) {
UserModel.update({ _id: this.id }, { 'overleaf.id': overleafId }, callback) UserModel.updateOne(
{ _id: this.id },
{ 'overleaf.id': overleafId },
callback
)
} }
logout(callback) { logout(callback) {
@ -618,7 +622,7 @@ class User {
} }
setV1Id(v1Id, callback) { setV1Id(v1Id, callback) {
UserModel.update( UserModel.updateOne(
{ {
_id: this._id _id: this._id
}, },

View file

@ -99,7 +99,7 @@ describe('CollaboratorsHandler', function() {
}) })
it('should remove the user from mongo', async function() { it('should remove the user from mongo', async function() {
this.ProjectMock.expects('update') this.ProjectMock.expects('updateOne')
.withArgs( .withArgs(
{ {
_id: this.project._id _id: this.project._id
@ -138,7 +138,7 @@ describe('CollaboratorsHandler', function() {
}) })
it('should remove the user from mongo', async function() { it('should remove the user from mongo', async function() {
this.ProjectMock.expects('update') this.ProjectMock.expects('updateOne')
.withArgs( .withArgs(
{ {
_id: this.oldArchivedProject._id _id: this.oldArchivedProject._id
@ -175,7 +175,7 @@ describe('CollaboratorsHandler', function() {
}) })
it('should remove the user from mongo', async function() { it('should remove the user from mongo', async function() {
this.ProjectMock.expects('update') this.ProjectMock.expects('updateOne')
.withArgs( .withArgs(
{ {
_id: this.archivedProject._id _id: this.archivedProject._id
@ -203,7 +203,7 @@ describe('CollaboratorsHandler', function() {
describe('addUserIdToProject', function() { describe('addUserIdToProject', function() {
describe('as readOnly', function() { describe('as readOnly', function() {
beforeEach(async function() { beforeEach(async function() {
this.ProjectMock.expects('update') this.ProjectMock.expects('updateOne')
.withArgs( .withArgs(
{ {
_id: this.project._id _id: this.project._id
@ -238,7 +238,7 @@ describe('CollaboratorsHandler', function() {
describe('as readAndWrite', function() { describe('as readAndWrite', function() {
beforeEach(async function() { beforeEach(async function() {
this.ProjectMock.expects('update') this.ProjectMock.expects('updateOne')
.withArgs( .withArgs(
{ {
_id: this.project._id _id: this.project._id
@ -289,7 +289,7 @@ describe('CollaboratorsHandler', function() {
this.userId, this.userId,
'readAndWrite' 'readAndWrite'
) )
// Project.update() should not be called. If it is, it will fail because // Project.updateOne() should not be called. If it is, it will fail because
// the mock is not set up. // the mock is not set up.
}) })
}) })
@ -348,7 +348,7 @@ describe('CollaboratorsHandler', function() {
.chain('exec') .chain('exec')
.resolves({ _id: projectId }) .resolves({ _id: projectId })
this.ProjectMock.expects('update') this.ProjectMock.expects('updateOne')
.withArgs( .withArgs(
{ {
_id: projectId _id: projectId
@ -394,51 +394,46 @@ describe('CollaboratorsHandler', function() {
}) })
.chain('exec') .chain('exec')
.resolves(this.projects) .resolves(this.projects)
this.ProjectMock.expects('update') this.ProjectMock.expects('updateMany')
.withArgs( .withArgs(
{ owner_ref: this.fromUserId }, { owner_ref: this.fromUserId },
{ $set: { owner_ref: this.toUserId } }, { $set: { owner_ref: this.toUserId } }
{ multi: true }
) )
.chain('exec') .chain('exec')
.resolves() .resolves()
this.ProjectMock.expects('update') this.ProjectMock.expects('updateMany')
.withArgs( .withArgs(
{ collaberator_refs: this.fromUserId }, { collaberator_refs: this.fromUserId },
{ {
$addToSet: { collaberator_refs: this.toUserId } $addToSet: { collaberator_refs: this.toUserId }
}, }
{ multi: true }
) )
.chain('exec') .chain('exec')
.resolves() .resolves()
this.ProjectMock.expects('update') this.ProjectMock.expects('updateMany')
.withArgs( .withArgs(
{ collaberator_refs: this.fromUserId }, { collaberator_refs: this.fromUserId },
{ {
$pull: { collaberator_refs: this.fromUserId } $pull: { collaberator_refs: this.fromUserId }
}, }
{ multi: true }
) )
.chain('exec') .chain('exec')
.resolves() .resolves()
this.ProjectMock.expects('update') this.ProjectMock.expects('updateMany')
.withArgs( .withArgs(
{ readOnly_refs: this.fromUserId }, { readOnly_refs: this.fromUserId },
{ {
$addToSet: { readOnly_refs: this.toUserId } $addToSet: { readOnly_refs: this.toUserId }
}, }
{ multi: true }
) )
.chain('exec') .chain('exec')
.resolves() .resolves()
this.ProjectMock.expects('update') this.ProjectMock.expects('updateMany')
.withArgs( .withArgs(
{ readOnly_refs: this.fromUserId }, { readOnly_refs: this.fromUserId },
{ {
$pull: { readOnly_refs: this.fromUserId } $pull: { readOnly_refs: this.fromUserId }
}, }
{ multi: true }
) )
.chain('exec') .chain('exec')
.resolves() .resolves()

View file

@ -34,8 +34,8 @@ describe('CollaboratorsInviteHandler', function() {
this.prototype.save = sinon.stub() this.prototype.save = sinon.stub()
this.findOne = sinon.stub() this.findOne = sinon.stub()
this.find = sinon.stub() this.find = sinon.stub()
this.remove = sinon.stub() this.deleteOne = sinon.stub()
this.count = sinon.stub() this.countDocuments = sinon.stub()
} }
constructor(options) { constructor(options) {
if (options == null) { if (options == null) {
@ -105,7 +105,7 @@ describe('CollaboratorsInviteHandler', function() {
describe('getInviteCount', function() { describe('getInviteCount', function() {
beforeEach(function() { beforeEach(function() {
this.ProjectInvite.count.callsArgWith(1, null, 2) this.ProjectInvite.countDocuments.callsArgWith(1, null, 2)
return (this.call = callback => { return (this.call = callback => {
return this.CollaboratorsInviteHandler.getInviteCount( return this.CollaboratorsInviteHandler.getInviteCount(
this.projectId, this.projectId,
@ -129,9 +129,12 @@ describe('CollaboratorsInviteHandler', function() {
}) })
}) })
describe('when model.count produces an error', function() { describe('when model.countDocuments produces an error', function() {
beforeEach(function() { beforeEach(function() {
return this.ProjectInvite.count.callsArgWith(1, new Error('woops')) return this.ProjectInvite.countDocuments.callsArgWith(
1,
new Error('woops')
)
}) })
it('should produce an error', function(done) { it('should produce an error', function(done) {
@ -391,7 +394,7 @@ describe('CollaboratorsInviteHandler', function() {
describe('revokeInvite', function() { describe('revokeInvite', function() {
beforeEach(function() { beforeEach(function() {
this.ProjectInvite.remove.callsArgWith(1, null) this.ProjectInvite.deleteOne.callsArgWith(1, null)
this.CollaboratorsInviteHandler._tryCancelInviteNotification = sinon this.CollaboratorsInviteHandler._tryCancelInviteNotification = sinon
.stub() .stub()
.callsArgWith(1, null) .callsArgWith(1, null)
@ -415,10 +418,10 @@ describe('CollaboratorsInviteHandler', function() {
}) })
}) })
it('should call ProjectInvite.remove', function(done) { it('should call ProjectInvite.deleteOne', function(done) {
return this.call(err => { return this.call(err => {
this.ProjectInvite.remove.callCount.should.equal(1) this.ProjectInvite.deleteOne.callCount.should.equal(1)
this.ProjectInvite.remove this.ProjectInvite.deleteOne
.calledWith({ projectId: this.projectId, _id: this.inviteId }) .calledWith({ projectId: this.projectId, _id: this.inviteId })
.should.equal(true) .should.equal(true)
return done() return done()
@ -440,7 +443,7 @@ describe('CollaboratorsInviteHandler', function() {
describe('when remove produces an error', function() { describe('when remove produces an error', function() {
beforeEach(function() { beforeEach(function() {
return this.ProjectInvite.remove.callsArgWith(1, new Error('woops')) return this.ProjectInvite.deleteOne.callsArgWith(1, new Error('woops'))
}) })
it('should produce an error', function(done) { it('should produce an error', function(done) {
@ -641,7 +644,7 @@ describe('CollaboratorsInviteHandler', function() {
this.CollaboratorsInviteHandler._tryCancelInviteNotification = sinon this.CollaboratorsInviteHandler._tryCancelInviteNotification = sinon
.stub() .stub()
.callsArgWith(1, null) .callsArgWith(1, null)
this.ProjectInvite.remove.callsArgWith(1, null) this.ProjectInvite.deleteOne.callsArgWith(1, null)
return (this.call = callback => { return (this.call = callback => {
return this.CollaboratorsInviteHandler.acceptInvite( return this.CollaboratorsInviteHandler.acceptInvite(
this.projectId, this.projectId,
@ -692,10 +695,10 @@ describe('CollaboratorsInviteHandler', function() {
}) })
}) })
it('should have called ProjectInvite.remove', function(done) { it('should have called ProjectInvite.deleteOne', function(done) {
return this.call(err => { return this.call(err => {
this.ProjectInvite.remove.callCount.should.equal(1) this.ProjectInvite.deleteOne.callCount.should.equal(1)
this.ProjectInvite.remove this.ProjectInvite.deleteOne
.calledWith({ _id: this.inviteId }) .calledWith({ _id: this.inviteId })
.should.equal(true) .should.equal(true)
return done() return done()
@ -763,9 +766,9 @@ describe('CollaboratorsInviteHandler', function() {
}) })
}) })
it('should not have called ProjectInvite.remove', function(done) { it('should not have called ProjectInvite.deleteOne', function(done) {
return this.call(err => { return this.call(err => {
this.ProjectInvite.remove.callCount.should.equal(0) this.ProjectInvite.deleteOne.callCount.should.equal(0)
return done() return done()
}) })
}) })
@ -800,9 +803,9 @@ describe('CollaboratorsInviteHandler', function() {
}) })
}) })
it('should not have called ProjectInvite.remove', function(done) { it('should not have called ProjectInvite.deleteOne', function(done) {
return this.call(err => { return this.call(err => {
this.ProjectInvite.remove.callCount.should.equal(0) this.ProjectInvite.deleteOne.callCount.should.equal(0)
return done() return done()
}) })
}) })
@ -848,17 +851,17 @@ describe('CollaboratorsInviteHandler', function() {
}) })
}) })
it('should not have called ProjectInvite.remove', function(done) { it('should not have called ProjectInvite.deleteOne', function(done) {
return this.call(err => { return this.call(err => {
this.ProjectInvite.remove.callCount.should.equal(0) this.ProjectInvite.deleteOne.callCount.should.equal(0)
return done() return done()
}) })
}) })
}) })
describe('when ProjectInvite.remove produces an error', function() { describe('when ProjectInvite.deleteOne produces an error', function() {
beforeEach(function() { beforeEach(function() {
return this.ProjectInvite.remove.callsArgWith(1, new Error('woops')) return this.ProjectInvite.deleteOne.callsArgWith(1, new Error('woops'))
}) })
it('should produce an error', function(done) { it('should produce an error', function(done) {
@ -893,9 +896,9 @@ describe('CollaboratorsInviteHandler', function() {
}) })
}) })
it('should have called ProjectInvite.remove', function(done) { it('should have called ProjectInvite.deleteOne', function(done) {
return this.call(err => { return this.call(err => {
this.ProjectInvite.remove.callCount.should.equal(1) this.ProjectInvite.deleteOne.callCount.should.equal(1)
return done() return done()
}) })
}) })

View file

@ -24,7 +24,7 @@ describe('OwnershipTransferHandler', function() {
} }
} }
this.ProjectModel = { this.ProjectModel = {
update: sinon.stub().returns({ updateOne: sinon.stub().returns({
exec: sinon.stub().resolves() exec: sinon.stub().resolves()
}) })
} }
@ -129,7 +129,7 @@ describe('OwnershipTransferHandler', function() {
this.project._id, this.project._id,
this.collaborator._id this.collaborator._id
) )
expect(this.ProjectModel.update).to.have.been.calledWith( expect(this.ProjectModel.updateOne).to.have.been.calledWith(
{ _id: this.project._id }, { _id: this.project._id },
sinon.match({ $set: { owner_ref: this.collaborator._id } }) sinon.match({ $set: { owner_ref: this.collaborator._id } })
) )
@ -140,7 +140,7 @@ describe('OwnershipTransferHandler', function() {
this.project._id, this.project._id,
this.user._id this.user._id
) )
expect(this.ProjectModel.update).not.to.have.been.called expect(this.ProjectModel.updateOne).not.to.have.been.called
}) })
it("should remove the user from the project's collaborators", async function() { it("should remove the user from the project's collaborators", async function() {

View file

@ -49,7 +49,7 @@ describe('ProjectCollabratecDetailsHandler', function() {
describe('initializeCollabratecProject', function() { describe('initializeCollabratecProject', function() {
describe('when update succeeds', function() { describe('when update succeeds', function() {
beforeEach(function() { beforeEach(function() {
this.ProjectModel.update = sinon.stub().yields() this.ProjectModel.updateOne = sinon.stub().yields()
return this.ProjectCollabratecDetailsHandler.initializeCollabratecProject( return this.ProjectCollabratecDetailsHandler.initializeCollabratecProject(
this.projectId, this.projectId,
this.userId, this.userId,
@ -71,7 +71,7 @@ describe('ProjectCollabratecDetailsHandler', function() {
] ]
} }
} }
return expect(this.ProjectModel.update).to.have.been.calledWith( return expect(this.ProjectModel.updateOne).to.have.been.calledWith(
{ _id: this.projectId }, { _id: this.projectId },
update, update,
this.callback this.callback
@ -81,7 +81,7 @@ describe('ProjectCollabratecDetailsHandler', function() {
describe('when update has error', function() { describe('when update has error', function() {
beforeEach(function() { beforeEach(function() {
this.ProjectModel.update = sinon.stub().yields('error') this.ProjectModel.updateOne = sinon.stub().yields('error')
return this.ProjectCollabratecDetailsHandler.initializeCollabratecProject( return this.ProjectCollabratecDetailsHandler.initializeCollabratecProject(
this.projectId, this.projectId,
this.userId, this.userId,
@ -98,7 +98,7 @@ describe('ProjectCollabratecDetailsHandler', function() {
describe('with invalid args', function() { describe('with invalid args', function() {
beforeEach(function() { beforeEach(function() {
this.ProjectModel.update = sinon.stub() this.ProjectModel.updateOne = sinon.stub()
return this.ProjectCollabratecDetailsHandler.initializeCollabratecProject( return this.ProjectCollabratecDetailsHandler.initializeCollabratecProject(
'bad-project-id', 'bad-project-id',
'bad-user-id', 'bad-user-id',
@ -109,7 +109,7 @@ describe('ProjectCollabratecDetailsHandler', function() {
}) })
it('should not update', function() { it('should not update', function() {
return expect(this.ProjectModel.update).not.to.have.been.called return expect(this.ProjectModel.updateOne).not.to.have.been.called
}) })
it('should callback with error', function() { it('should callback with error', function() {
@ -206,7 +206,7 @@ describe('ProjectCollabratecDetailsHandler', function() {
describe('linkCollabratecUserProject', function() { describe('linkCollabratecUserProject', function() {
describe('when update succeeds', function() { describe('when update succeeds', function() {
beforeEach(function() { beforeEach(function() {
this.ProjectModel.update = sinon.stub().yields() this.ProjectModel.updateOne = sinon.stub().yields()
return this.ProjectCollabratecDetailsHandler.linkCollabratecUserProject( return this.ProjectCollabratecDetailsHandler.linkCollabratecUserProject(
this.projectId, this.projectId,
this.userId, this.userId,
@ -235,7 +235,7 @@ describe('ProjectCollabratecDetailsHandler', function() {
} }
} }
} }
return expect(this.ProjectModel.update).to.have.been.calledWith( return expect(this.ProjectModel.updateOne).to.have.been.calledWith(
query, query,
update, update,
this.callback this.callback
@ -245,7 +245,7 @@ describe('ProjectCollabratecDetailsHandler', function() {
describe('when update has error', function() { describe('when update has error', function() {
beforeEach(function() { beforeEach(function() {
this.ProjectModel.update = sinon.stub().yields('error') this.ProjectModel.updateOne = sinon.stub().yields('error')
return this.ProjectCollabratecDetailsHandler.linkCollabratecUserProject( return this.ProjectCollabratecDetailsHandler.linkCollabratecUserProject(
this.projectId, this.projectId,
this.userId, this.userId,
@ -261,7 +261,7 @@ describe('ProjectCollabratecDetailsHandler', function() {
describe('with invalid args', function() { describe('with invalid args', function() {
beforeEach(function() { beforeEach(function() {
this.ProjectModel.update = sinon.stub() this.ProjectModel.updateOne = sinon.stub()
return this.ProjectCollabratecDetailsHandler.linkCollabratecUserProject( return this.ProjectCollabratecDetailsHandler.linkCollabratecUserProject(
'bad-project-id', 'bad-project-id',
'bad-user-id', 'bad-user-id',
@ -271,7 +271,7 @@ describe('ProjectCollabratecDetailsHandler', function() {
}) })
it('should not update', function() { it('should not update', function() {
return expect(this.ProjectModel.update).not.to.have.been.called return expect(this.ProjectModel.updateOne).not.to.have.been.called
}) })
it('should callback with error', function() { it('should callback with error', function() {
@ -298,7 +298,7 @@ describe('ProjectCollabratecDetailsHandler', function() {
describe('when update succeeds', function() { describe('when update succeeds', function() {
beforeEach(function() { beforeEach(function() {
this.ProjectModel.update = sinon.stub().yields() this.ProjectModel.updateOne = sinon.stub().yields()
return this.ProjectCollabratecDetailsHandler.setCollabratecUsers( return this.ProjectCollabratecDetailsHandler.setCollabratecUsers(
this.projectId, this.projectId,
this.collabratecUsers, this.collabratecUsers,
@ -312,7 +312,7 @@ describe('ProjectCollabratecDetailsHandler', function() {
collabratecUsers: this.collabratecUsers collabratecUsers: this.collabratecUsers
} }
} }
return expect(this.ProjectModel.update).to.have.been.calledWith( return expect(this.ProjectModel.updateOne).to.have.been.calledWith(
{ _id: this.projectId }, { _id: this.projectId },
update, update,
this.callback this.callback
@ -322,7 +322,7 @@ describe('ProjectCollabratecDetailsHandler', function() {
describe('when update has error', function() { describe('when update has error', function() {
beforeEach(function() { beforeEach(function() {
this.ProjectModel.update = sinon.stub().yields('error') this.ProjectModel.updateOne = sinon.stub().yields('error')
return this.ProjectCollabratecDetailsHandler.setCollabratecUsers( return this.ProjectCollabratecDetailsHandler.setCollabratecUsers(
this.projectId, this.projectId,
this.collabratecUsers, this.collabratecUsers,
@ -337,7 +337,7 @@ describe('ProjectCollabratecDetailsHandler', function() {
describe('with invalid project_id', function() { describe('with invalid project_id', function() {
beforeEach(function() { beforeEach(function() {
this.ProjectModel.update = sinon.stub() this.ProjectModel.updateOne = sinon.stub()
return this.ProjectCollabratecDetailsHandler.setCollabratecUsers( return this.ProjectCollabratecDetailsHandler.setCollabratecUsers(
'bad-project-id', 'bad-project-id',
this.collabratecUsers, this.collabratecUsers,
@ -346,7 +346,7 @@ describe('ProjectCollabratecDetailsHandler', function() {
}) })
it('should not update', function() { it('should not update', function() {
return expect(this.ProjectModel.update).not.to.have.been.called return expect(this.ProjectModel.updateOne).not.to.have.been.called
}) })
it('should callback with error', function() { it('should callback with error', function() {
@ -357,7 +357,7 @@ describe('ProjectCollabratecDetailsHandler', function() {
describe('with invalid user_id', function() { describe('with invalid user_id', function() {
beforeEach(function() { beforeEach(function() {
this.collabratecUsers[1].user_id = 'bad-user-id' this.collabratecUsers[1].user_id = 'bad-user-id'
this.ProjectModel.update = sinon.stub() this.ProjectModel.updateOne = sinon.stub()
return this.ProjectCollabratecDetailsHandler.setCollabratecUsers( return this.ProjectCollabratecDetailsHandler.setCollabratecUsers(
this.projectId, this.projectId,
this.collabratecUsers, this.collabratecUsers,
@ -366,7 +366,7 @@ describe('ProjectCollabratecDetailsHandler', function() {
}) })
it('should not update', function() { it('should not update', function() {
return expect(this.ProjectModel.update).not.to.have.been.called return expect(this.ProjectModel.updateOne).not.to.have.been.called
}) })
it('should callback with error', function() { it('should callback with error', function() {
@ -378,7 +378,7 @@ describe('ProjectCollabratecDetailsHandler', function() {
describe('unlinkCollabratecUserProject', function() { describe('unlinkCollabratecUserProject', function() {
describe('when update succeeds', function() { describe('when update succeeds', function() {
beforeEach(function() { beforeEach(function() {
this.ProjectModel.update = sinon.stub().yields() this.ProjectModel.updateOne = sinon.stub().yields()
return this.ProjectCollabratecDetailsHandler.unlinkCollabratecUserProject( return this.ProjectCollabratecDetailsHandler.unlinkCollabratecUserProject(
this.projectId, this.projectId,
this.userId, this.userId,
@ -395,7 +395,7 @@ describe('ProjectCollabratecDetailsHandler', function() {
} }
} }
} }
return expect(this.ProjectModel.update).to.have.been.calledWith( return expect(this.ProjectModel.updateOne).to.have.been.calledWith(
query, query,
update, update,
this.callback this.callback
@ -405,7 +405,7 @@ describe('ProjectCollabratecDetailsHandler', function() {
describe('when update has error', function() { describe('when update has error', function() {
beforeEach(function() { beforeEach(function() {
this.ProjectModel.update = sinon.stub().yields('error') this.ProjectModel.updateOne = sinon.stub().yields('error')
return this.ProjectCollabratecDetailsHandler.unlinkCollabratecUserProject( return this.ProjectCollabratecDetailsHandler.unlinkCollabratecUserProject(
this.projectId, this.projectId,
this.userId, this.userId,
@ -420,7 +420,7 @@ describe('ProjectCollabratecDetailsHandler', function() {
describe('with invalid args', function() { describe('with invalid args', function() {
beforeEach(function() { beforeEach(function() {
this.ProjectModel.update = sinon.stub() this.ProjectModel.updateOne = sinon.stub()
return this.ProjectCollabratecDetailsHandler.unlinkCollabratecUserProject( return this.ProjectCollabratecDetailsHandler.unlinkCollabratecUserProject(
'bad-project-id', 'bad-project-id',
'bad-user-id', 'bad-user-id',
@ -429,7 +429,7 @@ describe('ProjectCollabratecDetailsHandler', function() {
}) })
it('should not update', function() { it('should not update', function() {
return expect(this.ProjectModel.update).not.to.have.been.called return expect(this.ProjectModel.updateOne).not.to.have.been.called
}) })
it('should callback with error', function() { it('should callback with error', function() {
@ -441,7 +441,7 @@ describe('ProjectCollabratecDetailsHandler', function() {
describe('updateCollabratecUserIds', function() { describe('updateCollabratecUserIds', function() {
describe('when update succeeds', function() { describe('when update succeeds', function() {
beforeEach(function() { beforeEach(function() {
this.ProjectModel.update = sinon.stub().yields() this.ProjectModel.updateMany = sinon.stub().yields()
return this.ProjectCollabratecDetailsHandler.updateCollabratecUserIds( return this.ProjectCollabratecDetailsHandler.updateCollabratecUserIds(
this.userId, this.userId,
this.userId2, this.userId2,
@ -450,10 +450,9 @@ describe('ProjectCollabratecDetailsHandler', function() {
}) })
it('should update project model', function() { it('should update project model', function() {
return expect(this.ProjectModel.update).to.have.been.calledWith( return expect(this.ProjectModel.updateMany).to.have.been.calledWith(
{ 'collabratecUsers.user_id': this.userId }, { 'collabratecUsers.user_id': this.userId },
{ $set: { 'collabratecUsers.$.user_id': this.userId2 } }, { $set: { 'collabratecUsers.$.user_id': this.userId2 } },
{ multi: true },
this.callback this.callback
) )
}) })
@ -461,7 +460,7 @@ describe('ProjectCollabratecDetailsHandler', function() {
describe('when update has error', function() { describe('when update has error', function() {
beforeEach(function() { beforeEach(function() {
this.ProjectModel.update = sinon.stub().yields('error') this.ProjectModel.updateMany = sinon.stub().yields('error')
return this.ProjectCollabratecDetailsHandler.updateCollabratecUserIds( return this.ProjectCollabratecDetailsHandler.updateCollabratecUserIds(
this.userId, this.userId,
this.userId2, this.userId2,
@ -476,7 +475,7 @@ describe('ProjectCollabratecDetailsHandler', function() {
describe('with invalid old_user_id', function() { describe('with invalid old_user_id', function() {
beforeEach(function() { beforeEach(function() {
this.ProjectModel.update = sinon.stub() this.ProjectModel.updateOne = sinon.stub()
return this.ProjectCollabratecDetailsHandler.updateCollabratecUserIds( return this.ProjectCollabratecDetailsHandler.updateCollabratecUserIds(
'bad-user-id', 'bad-user-id',
this.userId2, this.userId2,
@ -485,7 +484,7 @@ describe('ProjectCollabratecDetailsHandler', function() {
}) })
it('should not update', function() { it('should not update', function() {
return expect(this.ProjectModel.update).not.to.have.been.called return expect(this.ProjectModel.updateOne).not.to.have.been.called
}) })
it('should callback with error', function() { it('should callback with error', function() {
@ -495,7 +494,7 @@ describe('ProjectCollabratecDetailsHandler', function() {
describe('with invalid new_user_id', function() { describe('with invalid new_user_id', function() {
beforeEach(function() { beforeEach(function() {
this.ProjectModel.update = sinon.stub() this.ProjectModel.updateOne = sinon.stub()
return this.ProjectCollabratecDetailsHandler.updateCollabratecUserIds( return this.ProjectCollabratecDetailsHandler.updateCollabratecUserIds(
this.userId, this.userId,
'bad-user-id', 'bad-user-id',
@ -504,7 +503,7 @@ describe('ProjectCollabratecDetailsHandler', function() {
}) })
it('should not update', function() { it('should not update', function() {
return expect(this.ProjectModel.update).not.to.have.been.called return expect(this.ProjectModel.updateOne).not.to.have.been.called
}) })
it('should callback with error', function() { it('should callback with error', function() {

View file

@ -162,7 +162,7 @@ describe('ProjectDeleter', function() {
describe('mark as deleted by external source', function() { describe('mark as deleted by external source', function() {
beforeEach(function() { beforeEach(function() {
this.ProjectMock.expects('update') this.ProjectMock.expects('updateOne')
.withArgs( .withArgs(
{ _id: this.project._id }, { _id: this.project._id },
{ deletedByExternalDataSource: true } { deletedByExternalDataSource: true }
@ -191,7 +191,7 @@ describe('ProjectDeleter', function() {
describe('unmarkAsDeletedByExternalSource', function() { describe('unmarkAsDeletedByExternalSource', function() {
beforeEach(async function() { beforeEach(async function() {
this.ProjectMock.expects('update') this.ProjectMock.expects('updateOne')
.withArgs( .withArgs(
{ _id: this.project._id }, { _id: this.project._id },
{ deletedByExternalDataSource: false } { deletedByExternalDataSource: false }
@ -220,11 +220,11 @@ describe('ProjectDeleter', function() {
.withArgs({ _id: project._id }) .withArgs({ _id: project._id })
.chain('exec') .chain('exec')
.resolves(project) .resolves(project)
this.ProjectMock.expects('remove') this.ProjectMock.expects('deleteOne')
.withArgs({ _id: project._id }) .withArgs({ _id: project._id })
.chain('exec') .chain('exec')
.resolves() .resolves()
this.DeletedProjectMock.expects('update') this.DeletedProjectMock.expects('updateOne')
.withArgs( .withArgs(
{ 'deleterData.deletedProjectId': project._id }, { 'deleterData.deletedProjectId': project._id },
{ {
@ -284,10 +284,10 @@ describe('ProjectDeleter', function() {
this.deleterData.deleterIpAddress = this.ip this.deleterData.deleterIpAddress = this.ip
this.deleterData.deleterId = this.user._id this.deleterData.deleterId = this.user._id
this.ProjectMock.expects('remove') this.ProjectMock.expects('deleteOne')
.chain('exec') .chain('exec')
.resolves() .resolves()
this.DeletedProjectMock.expects('update') this.DeletedProjectMock.expects('updateOne')
.withArgs( .withArgs(
{ 'deleterData.deletedProjectId': this.project._id }, { 'deleterData.deletedProjectId': this.project._id },
{ {
@ -306,10 +306,10 @@ describe('ProjectDeleter', function() {
}) })
it('should flushProjectToMongoAndDelete in doc updater', async function() { it('should flushProjectToMongoAndDelete in doc updater', async function() {
this.ProjectMock.expects('remove') this.ProjectMock.expects('deleteOne')
.chain('exec') .chain('exec')
.resolves() .resolves()
this.DeletedProjectMock.expects('update').resolves() this.DeletedProjectMock.expects('updateOne').resolves()
await this.ProjectDeleter.promises.deleteProject(this.project._id, { await this.ProjectDeleter.promises.deleteProject(this.project._id, {
deleterUser: this.user, deleterUser: this.user,
@ -321,10 +321,10 @@ describe('ProjectDeleter', function() {
}) })
it('should removeProjectFromAllTags', async function() { it('should removeProjectFromAllTags', async function() {
this.ProjectMock.expects('remove') this.ProjectMock.expects('deleteOne')
.chain('exec') .chain('exec')
.resolves() .resolves()
this.DeletedProjectMock.expects('update').resolves() this.DeletedProjectMock.expects('updateOne').resolves()
await this.ProjectDeleter.promises.deleteProject(this.project._id) await this.ProjectDeleter.promises.deleteProject(this.project._id)
sinon.assert.calledWith( sinon.assert.calledWith(
@ -340,11 +340,11 @@ describe('ProjectDeleter', function() {
}) })
it('should remove the project from Mongo', async function() { it('should remove the project from Mongo', async function() {
this.ProjectMock.expects('remove') this.ProjectMock.expects('deleteOne')
.withArgs({ _id: this.project._id }) .withArgs({ _id: this.project._id })
.chain('exec') .chain('exec')
.resolves() .resolves()
this.DeletedProjectMock.expects('update').resolves() this.DeletedProjectMock.expects('updateOne').resolves()
await this.ProjectDeleter.promises.deleteProject(this.project._id) await this.ProjectDeleter.promises.deleteProject(this.project._id)
this.ProjectMock.verify() this.ProjectMock.verify()
@ -372,7 +372,7 @@ describe('ProjectDeleter', function() {
}) })
.chain('exec') .chain('exec')
.resolves(deletedProject) .resolves(deletedProject)
this.DeletedProjectMock.expects('update') this.DeletedProjectMock.expects('updateOne')
.withArgs( .withArgs(
{ {
_id: deletedProject._id _id: deletedProject._id
@ -398,7 +398,7 @@ describe('ProjectDeleter', function() {
describe('expireDeletedProject', function() { describe('expireDeletedProject', function() {
beforeEach(async function() { beforeEach(async function() {
this.DeletedProjectMock.expects('update') this.DeletedProjectMock.expects('updateOne')
.withArgs( .withArgs(
{ {
_id: this.deletedProjects[0]._id _id: this.deletedProjects[0]._id
@ -458,7 +458,7 @@ describe('ProjectDeleter', function() {
.chain('exec') .chain('exec')
.resolves(this.project) .resolves(this.project)
this.ProjectMock.expects('update') this.ProjectMock.expects('updateOne')
.withArgs( .withArgs(
{ _id: this.project._id }, { _id: this.project._id },
{ {
@ -500,7 +500,7 @@ describe('ProjectDeleter', function() {
.chain('exec') .chain('exec')
.resolves(this.project) .resolves(this.project)
this.ProjectMock.expects('update') this.ProjectMock.expects('updateOne')
.withArgs({ _id: this.project._id }, { $set: { archived: archived } }) .withArgs({ _id: this.project._id }, { $set: { archived: archived } })
.resolves() .resolves()
}) })
@ -536,7 +536,7 @@ describe('ProjectDeleter', function() {
.chain('exec') .chain('exec')
.resolves(this.project) .resolves(this.project)
this.ProjectMock.expects('update') this.ProjectMock.expects('updateOne')
.withArgs( .withArgs(
{ _id: this.project._id }, { _id: this.project._id },
{ {
@ -575,7 +575,7 @@ describe('ProjectDeleter', function() {
.chain('exec') .chain('exec')
.resolves(this.project) .resolves(this.project)
this.ProjectMock.expects('update') this.ProjectMock.expects('updateOne')
.withArgs( .withArgs(
{ _id: this.project._id }, { _id: this.project._id },
{ $pull: { trashed: ObjectId(this.user._id) } } { $pull: { trashed: ObjectId(this.user._id) } }
@ -594,7 +594,7 @@ describe('ProjectDeleter', function() {
describe('restoreProject', function() { describe('restoreProject', function() {
beforeEach(function() { beforeEach(function() {
this.ProjectMock.expects('update') this.ProjectMock.expects('updateOne')
.withArgs( .withArgs(
{ {
_id: this.project._id _id: this.project._id

View file

@ -43,7 +43,7 @@ describe('ProjectDetailsHandler', function() {
exec: sinon.stub().resolves() exec: sinon.stub().resolves()
} }
this.ProjectModel = { this.ProjectModel = {
update: sinon.stub().returns(this.ProjectModelUpdateQuery) updateOne: sinon.stub().returns(this.ProjectModelUpdateQuery)
} }
this.UserGetter = { this.UserGetter = {
promises: { promises: {
@ -156,7 +156,7 @@ describe('ProjectDetailsHandler', function() {
this.project._id, this.project._id,
this.description this.description
) )
expect(this.ProjectModel.update).to.have.been.calledWith( expect(this.ProjectModel.updateOne).to.have.been.calledWith(
{ _id: this.project._id }, { _id: this.project._id },
{ description: this.description } { description: this.description }
) )
@ -170,7 +170,7 @@ describe('ProjectDetailsHandler', function() {
it('should update the project with the new name', async function() { it('should update the project with the new name', async function() {
await this.handler.promises.renameProject(this.project._id, this.newName) await this.handler.promises.renameProject(this.project._id, this.newName)
expect(this.ProjectModel.update).to.have.been.calledWith( expect(this.ProjectModel.updateOne).to.have.been.calledWith(
{ _id: this.project._id }, { _id: this.project._id },
{ name: this.newName } { name: this.newName }
) )
@ -191,7 +191,7 @@ describe('ProjectDetailsHandler', function() {
await expect(this.handler.promises.renameProject(this.project._id)).to.be await expect(this.handler.promises.renameProject(this.project._id)).to.be
.rejected .rejected
expect(this.TpdsUpdateSender.promises.moveEntity).not.to.have.been.called expect(this.TpdsUpdateSender.promises.moveEntity).not.to.have.been.called
expect(this.ProjectModel.update).not.to.have.been.called expect(this.ProjectModel.updateOne).not.to.have.been.called
}) })
}) })
@ -401,7 +401,7 @@ describe('ProjectDetailsHandler', function() {
this.project._id, this.project._id,
this.accessLevel this.accessLevel
) )
expect(this.ProjectModel.update).to.have.been.calledWith( expect(this.ProjectModel.updateOne).to.have.been.calledWith(
{ _id: this.project._id }, { _id: this.project._id },
{ publicAccesLevel: this.accessLevel } { publicAccesLevel: this.accessLevel }
) )
@ -459,7 +459,7 @@ describe('ProjectDetailsHandler', function() {
it('should not update the project with new tokens', async function() { it('should not update the project with new tokens', async function() {
await this.handler.promises.ensureTokensArePresent(this.project._id) await this.handler.promises.ensureTokensArePresent(this.project._id)
expect(this.ProjectModel.update).not.to.have.been.called expect(this.ProjectModel.updateOne).not.to.have.been.called
}) })
it('should produce the tokens without error', async function() { it('should produce the tokens without error', async function() {
@ -503,8 +503,8 @@ describe('ProjectDetailsHandler', function() {
.to.have.been.calledOnce .to.have.been.calledOnce
expect(this.ProjectTokenGenerator.readAndWriteToken).to.have.been expect(this.ProjectTokenGenerator.readAndWriteToken).to.have.been
.calledOnce .calledOnce
expect(this.ProjectModel.update).to.have.been.calledOnce expect(this.ProjectModel.updateOne).to.have.been.calledOnce
expect(this.ProjectModel.update).to.have.been.calledWith( expect(this.ProjectModel.updateOne).to.have.been.calledWith(
{ _id: this.project._id }, { _id: this.project._id },
{ {
$set: { $set: {
@ -534,7 +534,7 @@ describe('ProjectDetailsHandler', function() {
describe('clearTokens', function() { describe('clearTokens', function() {
it('clears the tokens from the project', async function() { it('clears the tokens from the project', async function() {
await this.handler.promises.clearTokens(this.project._id) await this.handler.promises.clearTokens(this.project._id)
expect(this.ProjectModel.update).to.have.been.calledWith( expect(this.ProjectModel.updateOne).to.have.been.calledWith(
{ _id: this.project._id }, { _id: this.project._id },
{ $unset: { tokens: 1 }, $set: { publicAccesLevel: 'private' } } { $unset: { tokens: 1 }, $set: { publicAccesLevel: 'private' } }
) )

View file

@ -96,7 +96,7 @@ describe('ProjectEntityUpdateHandler', function() {
) )
} }
this.ProjectModel = { this.ProjectModel = {
update: sinon.stub() updateOne: sinon.stub()
} }
this.ProjectGetter = { this.ProjectGetter = {
getProject: sinon.stub(), getProject: sinon.stub(),
@ -385,7 +385,7 @@ describe('ProjectEntityUpdateHandler', function() {
this.rootDocId = 'root-doc-id-123123' this.rootDocId = 'root-doc-id-123123'
}) })
it('should call Project.update when the doc exists and has a valid extension', function() { it('should call Project.updateOne when the doc exists and has a valid extension', function() {
this.ProjectEntityHandler.getDocPathByProjectIdAndDocId.yields( this.ProjectEntityHandler.getDocPathByProjectIdAndDocId.yields(
null, null,
`/main.tex` `/main.tex`
@ -396,12 +396,12 @@ describe('ProjectEntityUpdateHandler', function() {
this.rootDocId, this.rootDocId,
() => {} () => {}
) )
this.ProjectModel.update this.ProjectModel.updateOne
.calledWith({ _id: projectId }, { rootDoc_id: this.rootDocId }) .calledWith({ _id: projectId }, { rootDoc_id: this.rootDocId })
.should.equal(true) .should.equal(true)
}) })
it("should not call Project.update when the doc doesn't exist", function() { it("should not call Project.updateOne when the doc doesn't exist", function() {
this.ProjectEntityHandler.getDocPathByProjectIdAndDocId.yields( this.ProjectEntityHandler.getDocPathByProjectIdAndDocId.yields(
Errors.NotFoundError Errors.NotFoundError
) )
@ -411,7 +411,7 @@ describe('ProjectEntityUpdateHandler', function() {
this.rootDocId, this.rootDocId,
() => {} () => {}
) )
this.ProjectModel.update this.ProjectModel.updateOne
.calledWith({ _id: projectId }, { rootDoc_id: this.rootDocId }) .calledWith({ _id: projectId }, { rootDoc_id: this.rootDocId })
.should.equal(false) .should.equal(false)
}) })
@ -434,9 +434,9 @@ describe('ProjectEntityUpdateHandler', function() {
}) })
describe('unsetRootDoc', function() { describe('unsetRootDoc', function() {
it('should call Project.update', function() { it('should call Project.updateOne', function() {
this.ProjectEntityUpdateHandler.unsetRootDoc(projectId) this.ProjectEntityUpdateHandler.unsetRootDoc(projectId)
this.ProjectModel.update this.ProjectModel.updateOne
.calledWith({ _id: projectId }, { $unset: { rootDoc_id: true } }) .calledWith({ _id: projectId }, { $unset: { rootDoc_id: true } })
.should.equal(true) .should.equal(true)
}) })

View file

@ -83,7 +83,9 @@ describe('ProjectHistoryHandler', function() {
.stub() .stub()
.withArgs(project_id) .withArgs(project_id)
.callsArgWith(1, null, this.project) .callsArgWith(1, null, this.project)
this.ProjectModel.update = sinon.stub().callsArgWith(2, null, { n: 1 }) this.ProjectModel.updateOne = sinon
.stub()
.callsArgWith(2, null, { n: 1 })
return this.ProjectHistoryHandler.ensureHistoryExistsForProject( return this.ProjectHistoryHandler.ensureHistoryExistsForProject(
project_id, project_id,
this.callback this.callback
@ -101,7 +103,7 @@ describe('ProjectHistoryHandler', function() {
}) })
it('should set the new history id on the project', function() { it('should set the new history id on the project', function() {
return this.ProjectModel.update return this.ProjectModel.updateOne
.calledWith( .calledWith(
{ _id: project_id, 'overleaf.history.id': { $exists: false } }, { _id: project_id, 'overleaf.history.id': { $exists: false } },
{ 'overleaf.history.id': this.newHistoryId } { 'overleaf.history.id': this.newHistoryId }
@ -133,7 +135,7 @@ describe('ProjectHistoryHandler', function() {
.stub() .stub()
.withArgs(project_id) .withArgs(project_id)
.callsArgWith(1, null, this.project) .callsArgWith(1, null, this.project)
this.ProjectModel.update = sinon.stub() this.ProjectModel.updateOne = sinon.stub()
return this.ProjectHistoryHandler.ensureHistoryExistsForProject( return this.ProjectHistoryHandler.ensureHistoryExistsForProject(
project_id, project_id,
this.callback this.callback
@ -151,7 +153,7 @@ describe('ProjectHistoryHandler', function() {
}) })
it('should not set the new history id on the project', function() { it('should not set the new history id on the project', function() {
return this.ProjectModel.update.called.should.equal(false) return this.ProjectModel.updateOne.called.should.equal(false)
}) })
it('should not resync the project history', function() { it('should not resync the project history', function() {

View file

@ -29,7 +29,7 @@ describe('ProjectOptionsHandler', function() {
this.projectModel = Project = class Project { this.projectModel = Project = class Project {
constructor(options) {} constructor(options) {}
} }
this.projectModel.update = sinon.stub().yields() this.projectModel.updateOne = sinon.stub().yields()
this.handler = SandboxedModule.require(modulePath, { this.handler = SandboxedModule.require(modulePath, {
globals: { globals: {
@ -59,7 +59,7 @@ describe('ProjectOptionsHandler', function() {
describe('Setting the compiler', function() { describe('Setting the compiler', function() {
it('should perform and update on mongo', function(done) { it('should perform and update on mongo', function(done) {
this.handler.setCompiler(project_id, 'xeLaTeX', err => { this.handler.setCompiler(project_id, 'xeLaTeX', err => {
const args = this.projectModel.update.args[0] const args = this.projectModel.updateOne.args[0]
args[0]._id.should.equal(project_id) args[0]._id.should.equal(project_id)
args[1].compiler.should.equal('xelatex') args[1].compiler.should.equal('xelatex')
done() done()
@ -68,7 +68,7 @@ describe('ProjectOptionsHandler', function() {
it('should not perform and update on mongo if it is not a recognised compiler', function(done) { it('should not perform and update on mongo if it is not a recognised compiler', function(done) {
this.handler.setCompiler(project_id, 'something', err => { this.handler.setCompiler(project_id, 'something', err => {
this.projectModel.update.called.should.equal(false) this.projectModel.updateOne.called.should.equal(false)
done() done()
}) })
}) })
@ -77,7 +77,7 @@ describe('ProjectOptionsHandler', function() {
it('should callback with null', function(done) { it('should callback with null', function(done) {
this.handler.setCompiler(project_id, null, err => { this.handler.setCompiler(project_id, null, err => {
expect(err).to.be.undefined expect(err).to.be.undefined
this.projectModel.update.callCount.should.equal(0) this.projectModel.updateOne.callCount.should.equal(0)
done() done()
}) })
}) })
@ -85,7 +85,7 @@ describe('ProjectOptionsHandler', function() {
describe('when mongo update error occurs', function() { describe('when mongo update error occurs', function() {
beforeEach(function() { beforeEach(function() {
this.projectModel.update = sinon.stub().yields('error') this.projectModel.updateOne = sinon.stub().yields('error')
}) })
it('should callback with error', function(done) { it('should callback with error', function(done) {
@ -100,7 +100,7 @@ describe('ProjectOptionsHandler', function() {
describe('Setting the imageName', function() { describe('Setting the imageName', function() {
it('should perform and update on mongo', function(done) { it('should perform and update on mongo', function(done) {
this.handler.setImageName(project_id, 'texlive-1234.5', err => { this.handler.setImageName(project_id, 'texlive-1234.5', err => {
const args = this.projectModel.update.args[0] const args = this.projectModel.updateOne.args[0]
args[0]._id.should.equal(project_id) args[0]._id.should.equal(project_id)
args[1].imageName.should.equal('docker-repo/subdir/texlive-1234.5') args[1].imageName.should.equal('docker-repo/subdir/texlive-1234.5')
done() done()
@ -109,7 +109,7 @@ describe('ProjectOptionsHandler', function() {
it('should not perform and update on mongo if it is not a reconised compiler', function(done) { it('should not perform and update on mongo if it is not a reconised compiler', function(done) {
this.handler.setImageName(project_id, 'something', err => { this.handler.setImageName(project_id, 'something', err => {
this.projectModel.update.called.should.equal(false) this.projectModel.updateOne.called.should.equal(false)
done() done()
}) })
}) })
@ -118,7 +118,7 @@ describe('ProjectOptionsHandler', function() {
it('should callback with null', function(done) { it('should callback with null', function(done) {
this.handler.setImageName(project_id, null, err => { this.handler.setImageName(project_id, null, err => {
expect(err).to.be.undefined expect(err).to.be.undefined
this.projectModel.update.callCount.should.equal(0) this.projectModel.updateOne.callCount.should.equal(0)
done() done()
}) })
}) })
@ -126,7 +126,7 @@ describe('ProjectOptionsHandler', function() {
describe('when mongo update error occurs', function() { describe('when mongo update error occurs', function() {
beforeEach(function() { beforeEach(function() {
this.projectModel.update = sinon.stub().yields('error') this.projectModel.updateOne = sinon.stub().yields('error')
}) })
it('should callback with error', function(done) { it('should callback with error', function(done) {
@ -141,7 +141,7 @@ describe('ProjectOptionsHandler', function() {
describe('setting the spellCheckLanguage', function() { describe('setting the spellCheckLanguage', function() {
it('should perform and update on mongo', function(done) { it('should perform and update on mongo', function(done) {
this.handler.setSpellCheckLanguage(project_id, 'fr', err => { this.handler.setSpellCheckLanguage(project_id, 'fr', err => {
const args = this.projectModel.update.args[0] const args = this.projectModel.updateOne.args[0]
args[0]._id.should.equal(project_id) args[0]._id.should.equal(project_id)
args[1].spellCheckLanguage.should.equal('fr') args[1].spellCheckLanguage.should.equal('fr')
done() done()
@ -150,21 +150,21 @@ describe('ProjectOptionsHandler', function() {
it('should not perform and update on mongo if it is not a reconised compiler', function(done) { it('should not perform and update on mongo if it is not a reconised compiler', function(done) {
this.handler.setSpellCheckLanguage(project_id, 'no a lang', err => { this.handler.setSpellCheckLanguage(project_id, 'no a lang', err => {
this.projectModel.update.called.should.equal(false) this.projectModel.updateOne.called.should.equal(false)
done() done()
}) })
}) })
it('should perform and update on mongo if the language is blank (means turn it off)', function(done) { it('should perform and update on mongo if the language is blank (means turn it off)', function(done) {
this.handler.setSpellCheckLanguage(project_id, '', err => { this.handler.setSpellCheckLanguage(project_id, '', err => {
this.projectModel.update.called.should.equal(true) this.projectModel.updateOne.called.should.equal(true)
done() done()
}) })
}) })
describe('when mongo update error occurs', function() { describe('when mongo update error occurs', function() {
beforeEach(function() { beforeEach(function() {
this.projectModel.update = sinon.stub().yields('error') this.projectModel.updateOne = sinon.stub().yields('error')
}) })
it('should callback with error', function(done) { it('should callback with error', function(done) {
@ -179,7 +179,7 @@ describe('ProjectOptionsHandler', function() {
describe('setting the brandVariationId', function() { describe('setting the brandVariationId', function() {
it('should perform and update on mongo', function(done) { it('should perform and update on mongo', function(done) {
this.handler.setBrandVariationId(project_id, '123', err => { this.handler.setBrandVariationId(project_id, '123', err => {
const args = this.projectModel.update.args[0] const args = this.projectModel.updateOne.args[0]
args[0]._id.should.equal(project_id) args[0]._id.should.equal(project_id)
args[1].brandVariationId.should.equal('123') args[1].brandVariationId.should.equal('123')
done() done()
@ -188,21 +188,21 @@ describe('ProjectOptionsHandler', function() {
it('should not perform and update on mongo if there is no brand variation', function(done) { it('should not perform and update on mongo if there is no brand variation', function(done) {
this.handler.setBrandVariationId(project_id, null, err => { this.handler.setBrandVariationId(project_id, null, err => {
this.projectModel.update.called.should.equal(false) this.projectModel.updateOne.called.should.equal(false)
done() done()
}) })
}) })
it('should not perform and update on mongo if brand variation is an empty string', function(done) { it('should not perform and update on mongo if brand variation is an empty string', function(done) {
this.handler.setBrandVariationId(project_id, '', err => { this.handler.setBrandVariationId(project_id, '', err => {
this.projectModel.update.called.should.equal(false) this.projectModel.updateOne.called.should.equal(false)
done() done()
}) })
}) })
describe('when mongo update error occurs', function() { describe('when mongo update error occurs', function() {
beforeEach(function() { beforeEach(function() {
this.projectModel.update = sinon.stub().yields('error') this.projectModel.updateOne = sinon.stub().yields('error')
}) })
it('should callback with error', function(done) { it('should callback with error', function(done) {
@ -217,7 +217,7 @@ describe('ProjectOptionsHandler', function() {
describe('unsetting the brandVariationId', function() { describe('unsetting the brandVariationId', function() {
it('should perform and update on mongo', function(done) { it('should perform and update on mongo', function(done) {
this.handler.unsetBrandVariationId(project_id, err => { this.handler.unsetBrandVariationId(project_id, err => {
const args = this.projectModel.update.args[0] const args = this.projectModel.updateOne.args[0]
args[0]._id.should.equal(project_id) args[0]._id.should.equal(project_id)
expect(args[1]).to.deep.equal({ $unset: { brandVariationId: 1 } }) expect(args[1]).to.deep.equal({ $unset: { brandVariationId: 1 } })
done() done()
@ -226,7 +226,7 @@ describe('ProjectOptionsHandler', function() {
describe('when mongo update error occurs', function() { describe('when mongo update error occurs', function() {
beforeEach(function() { beforeEach(function() {
this.projectModel.update = sinon.stub().yields('error') this.projectModel.updateOne = sinon.stub().yields('error')
}) })
it('should callback with error', function(done) { it('should callback with error', function(done) {

View file

@ -27,7 +27,7 @@ describe('ProjectUpdateHandler', function() {
beforeEach(function() { beforeEach(function() {
let Project let Project
this.ProjectModel = Project = class Project {} this.ProjectModel = Project = class Project {}
this.ProjectModel.update = sinon.stub().callsArg(3) this.ProjectModel.updateOne = sinon.stub().callsArg(3)
return (this.handler = SandboxedModule.require(modulePath, { return (this.handler = SandboxedModule.require(modulePath, {
globals: { globals: {
console: console console: console
@ -53,7 +53,7 @@ describe('ProjectUpdateHandler', function() {
this.lastUpdatedBy, this.lastUpdatedBy,
err => { err => {
sinon.assert.calledWith( sinon.assert.calledWith(
this.ProjectModel.update, this.ProjectModel.updateOne,
{ {
_id: this.project_id, _id: this.project_id,
lastUpdated: { $lt: this.lastUpdatedAt } lastUpdated: { $lt: this.lastUpdatedAt }
@ -71,7 +71,7 @@ describe('ProjectUpdateHandler', function() {
it('should set smart fallbacks', function(done) { it('should set smart fallbacks', function(done) {
return this.handler.markAsUpdated(this.project_id, null, null, err => { return this.handler.markAsUpdated(this.project_id, null, null, err => {
sinon.assert.calledWithMatch( sinon.assert.calledWithMatch(
this.ProjectModel.update, this.ProjectModel.updateOne,
{ {
_id: this.project_id, _id: this.project_id,
lastUpdated: { $lt: this.fakeTime } lastUpdated: { $lt: this.fakeTime }
@ -90,7 +90,7 @@ describe('ProjectUpdateHandler', function() {
it('should send an update to mongo', function(done) { it('should send an update to mongo', function(done) {
const project_id = 'project_id' const project_id = 'project_id'
return this.handler.markAsOpened(project_id, err => { return this.handler.markAsOpened(project_id, err => {
const args = this.ProjectModel.update.args[0] const args = this.ProjectModel.updateOne.args[0]
args[0]._id.should.equal(project_id) args[0]._id.should.equal(project_id)
const date = args[1].lastOpened + '' const date = args[1].lastOpened + ''
const now = Date.now() + '' const now = Date.now() + ''
@ -104,7 +104,7 @@ describe('ProjectUpdateHandler', function() {
it('should send an update to mongo', function(done) { it('should send an update to mongo', function(done) {
const project_id = 'project_id' const project_id = 'project_id'
return this.handler.markAsInactive(project_id, err => { return this.handler.markAsInactive(project_id, err => {
const args = this.ProjectModel.update.args[0] const args = this.ProjectModel.updateOne.args[0]
args[0]._id.should.equal(project_id) args[0]._id.should.equal(project_id)
args[1].active.should.equal(false) args[1].active.should.equal(false)
return done() return done()
@ -116,7 +116,7 @@ describe('ProjectUpdateHandler', function() {
it('should send an update to mongo', function(done) { it('should send an update to mongo', function(done) {
const project_id = 'project_id' const project_id = 'project_id'
return this.handler.markAsActive(project_id, err => { return this.handler.markAsActive(project_id, err => {
const args = this.ProjectModel.update.args[0] const args = this.ProjectModel.updateOne.args[0]
args[0]._id.should.equal(project_id) args[0]._id.should.equal(project_id)
args[1].active.should.equal(true) args[1].active.should.equal(true)
return done() return done()

View file

@ -30,7 +30,7 @@ describe('ReferalAllocator', function() {
this.user_id = 'user-id-123' this.user_id = 'user-id-123'
this.new_user_id = 'new-user-id-123' this.new_user_id = 'new-user-id-123'
this.FeaturesUpdater.refreshFeatures = sinon.stub().yields() this.FeaturesUpdater.refreshFeatures = sinon.stub().yields()
this.User.update = sinon.stub().callsArgWith(3, null) this.User.updateOne = sinon.stub().callsArgWith(3, null)
this.User.findOne = sinon this.User.findOne = sinon
.stub() .stub()
.callsArgWith(2, null, { _id: this.user_id }) .callsArgWith(2, null, { _id: this.user_id })
@ -50,7 +50,7 @@ describe('ReferalAllocator', function() {
}) })
it('should update the referring user with the refered users id', function() { it('should update the referring user with the refered users id', function() {
this.User.update this.User.updateOne
.calledWith( .calledWith(
{ {
referal_id: this.referal_id referal_id: this.referal_id
@ -105,7 +105,7 @@ describe('ReferalAllocator', function() {
}) })
it('should not update the referring user with the refered users id', function() { it('should not update the referring user with the refered users id', function() {
this.User.update.called.should.equal(false) this.User.updateOne.called.should.equal(false)
}) })
it('should not assign the user a bonus', function() { it('should not assign the user a bonus', function() {
@ -130,7 +130,7 @@ describe('ReferalAllocator', function() {
}) })
it('should not update the referring user with the refered users id', function() { it('should not update the referring user with the refered users id', function() {
this.User.update.called.should.equal(false) this.User.updateOne.called.should.equal(false)
}) })
it('find the referring users id', function() { it('find the referring users id', function() {

View file

@ -68,7 +68,8 @@ describe('SubscriptionGroupHandler', function() {
this.EmailHandler = { sendEmail: sinon.stub() } this.EmailHandler = { sendEmail: sinon.stub() }
this.Subscription = { this.Subscription = {
update: sinon.stub().yields(), updateOne: sinon.stub().yields(),
updateMany: sinon.stub().yields(),
findOne: sinon.stub().yields() findOne: sinon.stub().yields()
} }
@ -143,38 +144,36 @@ describe('SubscriptionGroupHandler', function() {
}) })
it('replaces the admin_id', function() { it('replaces the admin_id', function() {
return this.Subscription.update return this.Subscription.updateOne
.calledWith({ admin_id: this.oldId }, { admin_id: this.newId }) .calledWith({ admin_id: this.oldId }, { admin_id: this.newId })
.should.equal(true) .should.equal(true)
}) })
it('replaces the manager_ids', function() { it('replaces the manager_ids', function() {
this.Subscription.update this.Subscription.updateMany
.calledWith( .calledWith(
{ manager_ids: 'ba5eba11' }, { manager_ids: 'ba5eba11' },
{ $addToSet: { manager_ids: '5ca1ab1e' } }, { $addToSet: { manager_ids: '5ca1ab1e' } }
{ multi: true }
) )
.should.equal(true) .should.equal(true)
return this.Subscription.update return this.Subscription.updateMany
.calledWith( .calledWith(
{ manager_ids: 'ba5eba11' }, { manager_ids: 'ba5eba11' },
{ $pull: { manager_ids: 'ba5eba11' } }, { $pull: { manager_ids: 'ba5eba11' } }
{ multi: true }
) )
.should.equal(true) .should.equal(true)
}) })
it('replaces the member ids', function() { it('replaces the member ids', function() {
this.Subscription.update this.Subscription.updateMany
.calledWith( .calledWith(
{ member_ids: this.oldId }, { member_ids: this.oldId },
{ $addToSet: { member_ids: this.newId } } { $addToSet: { member_ids: this.newId } }
) )
.should.equal(true) .should.equal(true)
return this.Subscription.update return this.Subscription.updateMany
.calledWith( .calledWith(
{ member_ids: this.oldId }, { member_ids: this.oldId },
{ $pull: { member_ids: this.oldId } } { $pull: { member_ids: this.oldId } }

View file

@ -40,9 +40,6 @@ describe('SubscriptionUpdater', function() {
this.updateStub = sinon.stub().callsArgWith(2, null) this.updateStub = sinon.stub().callsArgWith(2, null)
this.updateManyStub = sinon.stub().callsArgWith(2, null) this.updateManyStub = sinon.stub().callsArgWith(2, null)
this.findAndModifyStub = sinon
.stub()
.callsArgWith(2, null, this.subscription)
this.findOneAndUpdateStub = sinon this.findOneAndUpdateStub = sinon
.stub() .stub()
.callsArgWith(2, null, this.subscription) .callsArgWith(2, null, this.subscription)
@ -56,10 +53,9 @@ describe('SubscriptionUpdater', function() {
return subscription return subscription
} }
} }
this.SubscriptionModel.remove = sinon.stub().yields() this.SubscriptionModel.deleteOne = sinon.stub().yields()
this.SubscriptionModel.update = this.updateStub this.SubscriptionModel.updateOne = this.updateStub
this.SubscriptionModel.updateMany = this.updateManyStub this.SubscriptionModel.updateMany = this.updateManyStub
this.SubscriptionModel.findAndModify = this.findAndModifyStub
this.SubscriptionModel.findOneAndUpdate = this.findOneAndUpdateStub this.SubscriptionModel.findOneAndUpdate = this.findOneAndUpdateStub
this.SubscriptionLocator = { this.SubscriptionLocator = {
@ -138,8 +134,8 @@ describe('SubscriptionUpdater', function() {
$set: { admin_id: ObjectId(this.otherUserId) }, $set: { admin_id: ObjectId(this.otherUserId) },
$addToSet: { manager_ids: ObjectId(this.otherUserId) } $addToSet: { manager_ids: ObjectId(this.otherUserId) }
} }
this.SubscriptionModel.update.should.have.been.calledOnce this.SubscriptionModel.updateOne.should.have.been.calledOnce
this.SubscriptionModel.update.should.have.been.calledWith( this.SubscriptionModel.updateOne.should.have.been.calledWith(
query, query,
update update
) )
@ -166,8 +162,8 @@ describe('SubscriptionUpdater', function() {
manager_ids: [ObjectId(this.otherUserId)] manager_ids: [ObjectId(this.otherUserId)]
} }
} }
this.SubscriptionModel.update.should.have.been.calledOnce this.SubscriptionModel.updateOne.should.have.been.calledOnce
this.SubscriptionModel.update.should.have.been.calledWith( this.SubscriptionModel.updateOne.should.have.been.calledWith(
query, query,
update update
) )
@ -402,7 +398,7 @@ describe('SubscriptionUpdater', function() {
const insertOperation = { const insertOperation = {
$addToSet: { member_ids: { $each: [this.otherUserId] } } $addToSet: { member_ids: { $each: [this.otherUserId] } }
} }
this.findAndModifyStub this.updateStub
.calledWith(searchOps, insertOperation) .calledWith(searchOps, insertOperation)
.should.equal(true) .should.equal(true)
done() done()
@ -489,7 +485,7 @@ describe('SubscriptionUpdater', function() {
}) })
it('should remove the subscription', function() { it('should remove the subscription', function() {
this.SubscriptionModel.remove this.SubscriptionModel.deleteOne
.calledWith({ _id: this.subscription._id }) .calledWith({ _id: this.subscription._id })
.should.equal(true) .should.equal(true)
}) })

View file

@ -54,7 +54,7 @@ describe('TeamInvitesHandler', function() {
this.Subscription = { this.Subscription = {
findOne: sinon.stub().yields(), findOne: sinon.stub().yields(),
update: sinon.stub().yields() updateOne: sinon.stub().yields()
} }
this.EmailHandler = { this.EmailHandler = {
@ -201,7 +201,7 @@ describe('TeamInvitesHandler', function() {
this.subscription, this.subscription,
'John.Snow@example.com', 'John.Snow@example.com',
(err, invite) => { (err, invite) => {
this.Subscription.update this.Subscription.updateOne
.calledWith( .calledWith(
{ _id: new ObjectId('55153a8014829a865bbf700d') }, { _id: new ObjectId('55153a8014829a865bbf700d') },
{ $pull: { invited_emails: 'john.snow@example.com' } } { $pull: { invited_emails: 'john.snow@example.com' } }
@ -293,7 +293,7 @@ describe('TeamInvitesHandler', function() {
it('removes the invite from the subscription', function(done) { it('removes the invite from the subscription', function(done) {
this.TeamInvitesHandler.acceptInvite('dddddddd', this.user.id, () => { this.TeamInvitesHandler.acceptInvite('dddddddd', this.user.id, () => {
this.Subscription.update this.Subscription.updateOne
.calledWith( .calledWith(
{ _id: new ObjectId('55153a8014829a865bbf700d') }, { _id: new ObjectId('55153a8014829a865bbf700d') },
{ $pull: { teamInvites: { email: 'john.snow@example.com' } } } { $pull: { teamInvites: { email: 'john.snow@example.com' } } }
@ -311,14 +311,14 @@ describe('TeamInvitesHandler', function() {
this.subscription, this.subscription,
'jorah@example.com', 'jorah@example.com',
() => { () => {
this.Subscription.update this.Subscription.updateOne
.calledWith( .calledWith(
{ _id: new ObjectId('55153a8014829a865bbf700d') }, { _id: new ObjectId('55153a8014829a865bbf700d') },
{ $pull: { teamInvites: { email: 'jorah@example.com' } } } { $pull: { teamInvites: { email: 'jorah@example.com' } } }
) )
.should.eq(true) .should.eq(true)
this.Subscription.update this.Subscription.updateOne
.calledWith( .calledWith(
{ _id: new ObjectId('55153a8014829a865bbf700d') }, { _id: new ObjectId('55153a8014829a865bbf700d') },
{ $pull: { invited_emails: 'jorah@example.com' } } { $pull: { invited_emails: 'jorah@example.com' } }

View file

@ -21,7 +21,7 @@ const { assert } = require('chai')
describe('UserFeaturesUpdater', function() { describe('UserFeaturesUpdater', function() {
beforeEach(function() { beforeEach(function() {
this.User = { update: sinon.stub().callsArgWith(2) } this.User = { updateOne: sinon.stub().callsArgWith(2) }
return (this.UserFeaturesUpdater = SandboxedModule.require(modulePath, { return (this.UserFeaturesUpdater = SandboxedModule.require(modulePath, {
globals: { globals: {
console: console console: console
@ -49,7 +49,7 @@ describe('UserFeaturesUpdater', function() {
'features.versioning': true, 'features.versioning': true,
'features.collaborators': 10 'features.collaborators': 10
} }
this.User.update this.User.updateOne
.calledWith({ _id: user_id }, update) .calledWith({ _id: user_id }, update)
.should.equal(true) .should.equal(true)
features.should.deep.equal(this.features) features.should.deep.equal(this.features)

View file

@ -53,12 +53,12 @@ describe('SystemMessageManager', function() {
describe('clearMessages', function() { describe('clearMessages', function() {
beforeEach(function() { beforeEach(function() {
this.SystemMessage.remove = sinon.stub().callsArg(1) this.SystemMessage.deleteMany = sinon.stub().callsArg(1)
return this.SystemMessageManager.clearMessages(this.callback) return this.SystemMessageManager.clearMessages(this.callback)
}) })
it('should remove the messages from the database', function() { it('should remove the messages from the database', function() {
return this.SystemMessage.remove.calledWith({}).should.equal(true) return this.SystemMessage.deleteMany.calledWith({}).should.equal(true)
}) })
it('should return the callback', function() { it('should return the callback', function() {

View file

@ -124,7 +124,7 @@ describe('TagsHandler', function() {
describe('addProjectToTagName', function() { describe('addProjectToTagName', function() {
it('should call update in mongo', function(done) { it('should call update in mongo', function(done) {
this.TagMock.expects('update') this.TagMock.expects('updateOne')
.once() .once()
.withArgs( .withArgs(
{ name: this.tag.name, user_id: this.tag.userId }, { name: this.tag.name, user_id: this.tag.userId },
@ -148,12 +148,11 @@ describe('TagsHandler', function() {
describe('updateTagUserIds', function() { describe('updateTagUserIds', function() {
it('should call update in mongo', function(done) { it('should call update in mongo', function(done) {
this.newUserId = ObjectId().toString() this.newUserId = ObjectId().toString()
this.TagMock.expects('update') this.TagMock.expects('updateMany')
.once() .once()
.withArgs( .withArgs(
{ user_id: this.userId }, { user_id: this.userId },
{ $set: { user_id: this.newUserId } }, { $set: { user_id: this.newUserId } }
{ multi: true }
) )
.yields() .yields()
this.TagsHandler.updateTagUserIds(this.userId, this.newUserId, err => { this.TagsHandler.updateTagUserIds(this.userId, this.newUserId, err => {
@ -167,7 +166,7 @@ describe('TagsHandler', function() {
describe('removeProjectFromTag', function() { describe('removeProjectFromTag', function() {
describe('with a valid tag_id', function() { describe('with a valid tag_id', function() {
it('should call update in mongo', function(done) { it('should call update in mongo', function(done) {
this.TagMock.expects('update') this.TagMock.expects('updateOne')
.once() .once()
.withArgs( .withArgs(
{ {
@ -195,7 +194,7 @@ describe('TagsHandler', function() {
describe('removeProjectFromAllTags', function() { describe('removeProjectFromAllTags', function() {
it('should pull the project id from the tag', function(done) { it('should pull the project id from the tag', function(done) {
this.TagMock.expects('update') this.TagMock.expects('updateMany')
.once() .once()
.withArgs( .withArgs(
{ {
@ -221,7 +220,7 @@ describe('TagsHandler', function() {
describe('deleteTag', function() { describe('deleteTag', function() {
describe('with a valid tag_id', function() { describe('with a valid tag_id', function() {
it('should call remove in mongo', function(done) { it('should call remove in mongo', function(done) {
this.TagMock.expects('remove') this.TagMock.expects('deleteOne')
.once() .once()
.withArgs({ _id: this.tagId, user_id: this.userId }) .withArgs({ _id: this.tagId, user_id: this.userId })
.yields() .yields()
@ -238,7 +237,7 @@ describe('TagsHandler', function() {
describe('with a valid tag_id', function() { describe('with a valid tag_id', function() {
it('should call remove in mongo', function(done) { it('should call remove in mongo', function(done) {
this.newName = 'new name' this.newName = 'new name'
this.TagMock.expects('update') this.TagMock.expects('updateOne')
.once() .once()
.withArgs( .withArgs(
{ _id: this.tagId, user_id: this.userId }, { _id: this.tagId, user_id: this.userId },

View file

@ -62,7 +62,7 @@ describe('TemplatesManager', function() {
getProjectDescription: sinon.stub(), getProjectDescription: sinon.stub(),
fixProjectName: sinon.stub().returns(this.templateName) fixProjectName: sinon.stub().returns(this.templateName)
} }
this.Project = { update: sinon.stub().callsArgWith(3, null) } this.Project = { updateOne: sinon.stub().callsArgWith(3, null) }
this.FileWriter = { ensureDumpFolderExists: sinon.stub().callsArg(0) } this.FileWriter = { ensureDumpFolderExists: sinon.stub().callsArg(0) }
this.TemplatesManager = SandboxedModule.require(modulePath, { this.TemplatesManager = SandboxedModule.require(modulePath, {
globals: { globals: {
@ -174,7 +174,7 @@ describe('TemplatesManager', function() {
}) })
it('should update project', function() { it('should update project', function() {
return this.Project.update.should.have.been.calledWithMatch( return this.Project.updateOne.should.have.been.calledWithMatch(
{ _id: this.project_id }, { _id: this.project_id },
{ {
fromV1TemplateId: this.templateId, fromV1TemplateId: this.templateId,

View file

@ -123,22 +123,22 @@ describe('TokenAccessHandler', function() {
describe('addReadOnlyUserToProject', function() { describe('addReadOnlyUserToProject', function() {
beforeEach(function() { beforeEach(function() {
return (this.Project.update = sinon.stub().callsArgWith(2, null)) return (this.Project.updateOne = sinon.stub().callsArgWith(2, null))
}) })
it('should call Project.update', function(done) { it('should call Project.updateOne', function(done) {
return this.TokenAccessHandler.addReadOnlyUserToProject( return this.TokenAccessHandler.addReadOnlyUserToProject(
this.userId, this.userId,
this.projectId, this.projectId,
err => { err => {
expect(this.Project.update.callCount).to.equal(1) expect(this.Project.updateOne.callCount).to.equal(1)
expect( expect(
this.Project.update.calledWith({ this.Project.updateOne.calledWith({
_id: this.projectId _id: this.projectId
}) })
).to.equal(true) ).to.equal(true)
expect( expect(
this.Project.update.lastCall.args[1]['$addToSet'] this.Project.updateOne.lastCall.args[1].$addToSet
).to.have.keys('tokenAccessReadOnly_refs') ).to.have.keys('tokenAccessReadOnly_refs')
return done() return done()
} }
@ -156,9 +156,9 @@ describe('TokenAccessHandler', function() {
) )
}) })
describe('when Project.update produces an error', function() { describe('when Project.updateOne produces an error', function() {
beforeEach(function() { beforeEach(function() {
return (this.Project.update = sinon return (this.Project.updateOne = sinon
.stub() .stub()
.callsArgWith(2, new Error('woops'))) .callsArgWith(2, new Error('woops')))
}) })
@ -178,22 +178,22 @@ describe('TokenAccessHandler', function() {
describe('addReadAndWriteUserToProject', function() { describe('addReadAndWriteUserToProject', function() {
beforeEach(function() { beforeEach(function() {
return (this.Project.update = sinon.stub().callsArgWith(2, null)) return (this.Project.updateOne = sinon.stub().callsArgWith(2, null))
}) })
it('should call Project.update', function(done) { it('should call Project.updateOne', function(done) {
return this.TokenAccessHandler.addReadAndWriteUserToProject( return this.TokenAccessHandler.addReadAndWriteUserToProject(
this.userId, this.userId,
this.projectId, this.projectId,
err => { err => {
expect(this.Project.update.callCount).to.equal(1) expect(this.Project.updateOne.callCount).to.equal(1)
expect( expect(
this.Project.update.calledWith({ this.Project.updateOne.calledWith({
_id: this.projectId _id: this.projectId
}) })
).to.equal(true) ).to.equal(true)
expect( expect(
this.Project.update.lastCall.args[1]['$addToSet'] this.Project.updateOne.lastCall.args[1].$addToSet
).to.have.keys('tokenAccessReadAndWrite_refs') ).to.have.keys('tokenAccessReadAndWrite_refs')
return done() return done()
} }
@ -211,9 +211,9 @@ describe('TokenAccessHandler', function() {
) )
}) })
describe('when Project.update produces an error', function() { describe('when Project.updateOne produces an error', function() {
beforeEach(function() { beforeEach(function() {
return (this.Project.update = sinon return (this.Project.updateOne = sinon
.stub() .stub()
.callsArgWith(2, new Error('woops'))) .callsArgWith(2, new Error('woops')))
}) })

View file

@ -78,7 +78,7 @@ describe('SAMLIdentityManager', function() {
findOne: sinon.stub().returns({ findOne: sinon.stub().returns({
exec: sinon.stub().resolves() exec: sinon.stub().resolves()
}), }),
update: sinon.stub().returns({ updateOne: sinon.stub().returns({
exec: sinon.stub().resolves() exec: sinon.stub().resolves()
}) })
}) })
@ -226,7 +226,7 @@ describe('SAMLIdentityManager', function() {
expect(error).to.exist expect(error).to.exist
expect(error).to.equal(anError) expect(error).to.equal(anError)
expect(this.EmailHandler.sendEmail).to.not.have.been.called expect(this.EmailHandler.sendEmail).to.not.have.been.called
expect(this.User.update).to.not.have.been.called expect(this.User.updateOne).to.not.have.been.called
} }
}) })
}) })
@ -275,7 +275,7 @@ describe('SAMLIdentityManager', function() {
ipAddress: '0:0:0:0' ipAddress: '0:0:0:0'
}, },
() => { () => {
expect(this.User.update).to.have.been.called expect(this.User.updateOne).to.have.been.called
expect(this.EmailHandler.sendEmail).to.have.been.calledOnce expect(this.EmailHandler.sendEmail).to.have.been.calledOnce
const emailArgs = this.EmailHandler.sendEmail.lastCall.args const emailArgs = this.EmailHandler.sendEmail.lastCall.args
expect(emailArgs[0]).to.equal('securityAlert') expect(emailArgs[0]).to.equal('securityAlert')
@ -332,7 +332,7 @@ describe('SAMLIdentityManager', function() {
} }
} }
} }
expect(this.User.update).to.have.been.calledOnce.and.calledWithMatch( expect(this.User.updateOne).to.have.been.calledOnce.and.calledWithMatch(
query, query,
update update
) )
@ -346,7 +346,7 @@ describe('SAMLIdentityManager', function() {
'Overleaf University', 'Overleaf University',
this.auditLog this.auditLog
) )
expect(this.User.update).to.have.been.called expect(this.User.updateOne).to.have.been.called
expect(this.EmailHandler.sendEmail).to.have.been.calledOnce expect(this.EmailHandler.sendEmail).to.have.been.calledOnce
const emailArgs = this.EmailHandler.sendEmail.lastCall.args const emailArgs = this.EmailHandler.sendEmail.lastCall.args
expect(emailArgs[0]).to.equal('securityAlert') expect(emailArgs[0]).to.equal('securityAlert')
@ -376,7 +376,7 @@ describe('SAMLIdentityManager', function() {
expect(error).to.exist expect(error).to.exist
expect(error).to.equal(anError) expect(error).to.equal(anError)
expect(this.EmailHandler.sendEmail).to.not.have.been.called expect(this.EmailHandler.sendEmail).to.not.have.been.called
expect(this.User.update).to.not.have.been.called expect(this.User.updateOne).to.not.have.been.called
} }
}) })
}) })

View file

@ -147,7 +147,7 @@ describe('UserDeleter', function() {
describe('when no options are passed', function() { describe('when no options are passed', function() {
beforeEach(function() { beforeEach(function() {
this.DeletedUserMock.expects('update') this.DeletedUserMock.expects('updateOne')
.withArgs( .withArgs(
{ 'deleterData.deletedUserId': this.userId }, { 'deleterData.deletedUserId': this.userId },
this.deletedUser, this.deletedUser,
@ -274,7 +274,7 @@ describe('UserDeleter', function() {
this.deletedUser.deleterData.deleterIpAddress = this.ipAddress this.deletedUser.deleterData.deleterIpAddress = this.ipAddress
this.deletedUser.deleterData.deleterId = this.deleterId this.deletedUser.deleterData.deleterId = this.deleterId
this.DeletedUserMock.expects('update') this.DeletedUserMock.expects('updateOne')
.withArgs( .withArgs(
{ 'deleterData.deletedUserId': this.userId }, { 'deleterData.deletedUserId': this.userId },
this.deletedUser, this.deletedUser,

View file

@ -26,7 +26,7 @@ const EmailHelper = require('../../../../app/src/Features/Helpers/EmailHelper')
describe('UserRegistrationHandler', function() { describe('UserRegistrationHandler', function() {
beforeEach(function() { beforeEach(function() {
this.user = { _id: (this.user_id = '31j2lk21kjl') } this.user = { _id: (this.user_id = '31j2lk21kjl') }
this.User = { update: sinon.stub().callsArgWith(2) } this.User = { updateOne: sinon.stub().callsArgWith(2) }
this.UserGetter = { getUserByAnyEmail: sinon.stub() } this.UserGetter = { getUserByAnyEmail: sinon.stub() }
this.UserCreator = { this.UserCreator = {
createNewUser: sinon.stub().callsArgWith(2, null, this.user) createNewUser: sinon.stub().callsArgWith(2, null, this.user)
@ -129,7 +129,7 @@ describe('UserRegistrationHandler', function() {
it('should set holding account to false', function(done) { it('should set holding account to false', function(done) {
return this.handler.registerNewUser(this.passingRequest, err => { return this.handler.registerNewUser(this.passingRequest, err => {
const update = this.User.update.args[0] const update = this.User.updateOne.args[0]
assert.deepEqual(update[0], { _id: this.user._id }) assert.deepEqual(update[0], { _id: this.user._id })
assert.deepEqual(update[1], { $set: { holdingAccount: false } }) assert.deepEqual(update[1], { $set: { holdingAccount: false } })
return done() return done()

View file

@ -43,13 +43,13 @@ describe('UserMembershipHandler', function() {
_id: 'mock-institution-id', _id: 'mock-institution-id',
v1Id: 123, v1Id: 123,
managerIds: [ObjectId(), ObjectId(), ObjectId()], managerIds: [ObjectId(), ObjectId(), ObjectId()],
update: sinon.stub().yields(null) updateOne: sinon.stub().yields(null)
} }
this.publisher = { this.publisher = {
_id: 'mock-publisher-id', _id: 'mock-publisher-id',
slug: 'slug', slug: 'slug',
managerIds: [ObjectId(), ObjectId()], managerIds: [ObjectId(), ObjectId()],
update: sinon.stub().yields(null) updateOne: sinon.stub().yields(null)
} }
this.UserMembershipViewModel = { this.UserMembershipViewModel = {
@ -228,7 +228,7 @@ describe('UserMembershipHandler', function() {
EntityConfigs.institution, EntityConfigs.institution,
this.email, this.email,
(error, user) => { (error, user) => {
assertCalledWith(this.institution.update, { assertCalledWith(this.institution.updateOne, {
$addToSet: { managerIds: this.newUser._id } $addToSet: { managerIds: this.newUser._id }
}) })
return done() return done()
@ -258,8 +258,8 @@ describe('UserMembershipHandler', function() {
EntityConfigs.institution, EntityConfigs.institution,
this.newUser._id, this.newUser._id,
(error, user) => { (error, user) => {
const { lastCall } = this.institution.update const { lastCall } = this.institution.updateOne
assertCalledWith(this.institution.update, { assertCalledWith(this.institution.updateOne, {
$pull: { managerIds: this.newUser._id } $pull: { managerIds: this.newUser._id }
}) })
return done() return done()