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

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

GitOrigin-RevId: 45a284435c88898d96769ab258651fb8d6d20ff5
This commit is contained in:
Jakob Ackermann 2020-11-02 15:57:41 +01:00 committed by Copybot
parent 6a837ce457
commit e249a2e5be
60 changed files with 671 additions and 454 deletions

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -38,7 +38,7 @@ const SubscriptionGroupHandler = {
},
replaceUserReferencesInGroups(oldId, newId, callback) {
return Subscription.updateOne(
return Subscription.update(
{ admin_id: oldId },
{ admin_id: newId },
function(error) {
@ -118,12 +118,22 @@ var replaceInArray = function(model, property, oldValue, newValue, callback) {
const setOldValue = {}
setOldValue[property] = oldValue
model.updateMany(query, { $addToSet: setNewValue }, function(error) {
if (error) {
return callback(error)
return model.update(
query,
{ $addToSet: setNewValue },
{ 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) {

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -0,0 +1,29 @@
/* 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,15 +10,7 @@ const SubscriptionSchema = new Schema({
ref: 'User',
index: { unique: true, dropDups: true }
},
manager_ids: {
type: [ObjectId],
ref: 'User',
required: true,
validate: function(managers) {
// require at least one manager
return !!managers.length
}
},
manager_ids: { type: [ObjectId], ref: 'User', required: true },
member_ids: [{ type: ObjectId, ref: 'User' }],
invited_emails: [String],
teamInvites: [TeamInviteSchema],
@ -40,6 +32,11 @@ 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
SubscriptionSchema.method('fetchV1Data', function(callback) {
callback(null, this)

View file

@ -42,13 +42,14 @@ module.exports = settings =
# ---------
mongo:
options: {
appname: 'web'
useUnifiedTopology: (process.env['MONGO_USE_UNIFIED_TOPOLOGY'] || 'true') == 'true',
poolSize: parseInt(process.env['MONGO_POOL_SIZE'], 10) || 10,
serverSelectionTimeoutMS: parseInt(process.env['MONGO_SERVER_SELECTION_TIMEOUT'], 10) || 60000,
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"
poolSize: parseInt(process.env['MONGO_POOL_SIZE'], 10) || 10
socketTimeoutMS: parseInt(process.env['MONGO_SOCKET_TIMEOUT'], 10) || 30000
redis:
web:

View file

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

View file

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

View file

@ -12051,9 +12051,9 @@
}
},
"bson": {
"version": "1.1.5",
"resolved": "https://registry.npmjs.org/bson/-/bson-1.1.5.tgz",
"integrity": "sha512-kDuEzldR21lHciPQAIulLs1LZlCXdLziXI6Mb/TDkwXhb//UORJNPXgcRs2CuO4H0DcMkpfT3/ySsP3unoZjBg=="
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/bson/-/bson-1.0.4.tgz",
"integrity": "sha512-0Ib4Zy4vANsueMULLnoYfaVNK0xOFZ+ZQ3IpQbZRMjf1fXh5ASVtjnETbyAgkKet0PYnZibw6drFX1D20sg9lw=="
},
"buffer": {
"version": "4.9.1",
@ -12112,6 +12112,11 @@
"integrity": "sha512-4/rOEg86jivtPTeOUUT61jJO1Ya1TrR/OkqCSZDyq84WJh3LuuiphBYJN+fm5xufIk4XAFcEwte/8WzC8If/1g==",
"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": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/buffer-xor/-/buffer-xor-1.0.3.tgz",
@ -14427,7 +14432,7 @@
"d64": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/d64/-/d64-1.0.0.tgz",
"integrity": "sha512-5eNy3WZziVYnrogqgXhcdEmqcDB2IHurTqLcrgssJsfkMVCUoUaZpK6cJjxxvLV2dUm5SuJMNcYfVGoin9UIRw=="
"integrity": "sha1-QAKofoUMv8n52XBrYPymE6MzbpA="
},
"damerau-levenshtein": {
"version": "1.0.6",
@ -15184,6 +15189,11 @@
}
}
},
"each-series": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/each-series/-/each-series-1.0.0.tgz",
"integrity": "sha512-4MQloCGGCmT5GJZK5ibgJSvTK1c1QSrNlDvLk6fEyRxjZnXjl+NNFfzhfXpmnWh33Owc9D9klrdzCUi7yc9r4Q=="
},
"east": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/east/-/east-1.1.0.tgz",
@ -19468,6 +19478,11 @@
"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": {
"version": "2.8.8",
"resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.8.tgz",
@ -20682,7 +20697,7 @@
"is-subset": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/is-subset/-/is-subset-0.1.1.tgz",
"integrity": "sha512-6Ybun0IkarhmEqxXCNw/C0bna6Zb/TkfUX9UbwJtK6ObwAVCxmAP308WWTHviM/zAqXk05cdhYsUsZeGQh99iw==",
"integrity": "sha1-ilkRfZMt4d4A8kX83TnOQ/HpOaY=",
"dev": true
},
"is-svg": {
@ -21590,9 +21605,9 @@
}
},
"kareem": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/kareem/-/kareem-2.3.1.tgz",
"integrity": "sha512-l3hLhffs9zqoDe8zjmb/mAN4B8VT3L56EUvKNqLFVs9YlFA+zx7ke1DO8STAdDyYNkeSo1nKmjuvQeI12So8Xw=="
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/kareem/-/kareem-1.5.0.tgz",
"integrity": "sha512-DFYc05y1WSs6Ar++MHYRYu7/5r5356WDaKk8tQ8m6rlXD3VLpyG6Np81U78/wWJ4b5hjFXS7HkJNYrs85VypQA=="
},
"karma": {
"version": "5.0.4",
@ -22085,7 +22100,7 @@
"keycode": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/keycode/-/keycode-2.2.0.tgz",
"integrity": "sha512-ps3I9jAdNtRpJrbBvQjpzyFbss/skHqzS+eu4RxKLaEAtFqkjZaB6TZMSivPbLxf4K7VI4SjR0P5mRCX5+Q25A=="
"integrity": "sha1-PQr1bce4uOXLqNCpfxByBO7CKwQ="
},
"killable": {
"version": "1.0.1",
@ -22572,12 +22587,12 @@
"lodash.at": {
"version": "4.6.0",
"resolved": "https://registry.npmjs.org/lodash.at/-/lodash.at-4.6.0.tgz",
"integrity": "sha512-GOTh0SEp+Yosnlpjic+8cl2WM9MykorogkGA9xyIFkkObQ3H3kNZqZ+ohuq4K3FrSVo7hMcZBMataJemrxC3BA=="
"integrity": "sha1-k83OZk8KGZTqM9181A4jr9EbD/g="
},
"lodash.camelcase": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz",
"integrity": "sha512-TwuEnCnxbc3rAvhf/LbG7tJUDzhqXyFnv3dtzLOPgCG/hODL7WFnsbwktkD7yUV0RrreP/l1PALq/YSg6VvjlA=="
"integrity": "sha1-soqmKIorn8ZRA1x3EfZathkDMaY="
},
"lodash.defaults": {
"version": "4.2.0",
@ -22597,7 +22612,7 @@
"lodash.frompairs": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/lodash.frompairs/-/lodash.frompairs-4.0.1.tgz",
"integrity": "sha512-dvqe2I+cO5MzXCMhUnfYFa9MD+/760yx2aTAN1lqEcEkf896TxgrX373igVdqSJj6tQd0jnSLE1UMuKufqqxFw=="
"integrity": "sha1-vE5SB/onV8E25XNhTpZkUGsrG9I="
},
"lodash.get": {
"version": "4.4.2",
@ -22607,7 +22622,7 @@
"lodash.has": {
"version": "4.5.2",
"resolved": "https://registry.npmjs.org/lodash.has/-/lodash.has-4.5.2.tgz",
"integrity": "sha512-rnYUdIo6xRCJnQmbVFEwcxF144erlD+M3YcJUVesflU9paQaE8p+fJDcIQrlMYbxoANFL+AB9hZrzSBBk5PL+g=="
"integrity": "sha1-0Z9NwQlQWMzL4rDN9O4P5Ko3yGI="
},
"lodash.includes": {
"version": "4.3.0",
@ -22622,7 +22637,7 @@
"lodash.isequal": {
"version": "4.5.0",
"resolved": "https://registry.npmjs.org/lodash.isequal/-/lodash.isequal-4.5.0.tgz",
"integrity": "sha512-pDo3lu8Jhfjqls6GkMgpahsF9kCyayhgykjyLMNFTKWrpVdAQtYyB4muAMWozBB4ig/dtWAmsMxLEI8wuz+DYQ==",
"integrity": "sha1-QVxEePK8wwEgwizhDtMib30+GOA=",
"dev": true
},
"lodash.isinteger": {
@ -22670,7 +22685,7 @@
"lodash.sortby": {
"version": "4.7.0",
"resolved": "https://registry.npmjs.org/lodash.sortby/-/lodash.sortby-4.7.0.tgz",
"integrity": "sha512-HDWXG8isMntAyRF5vZ7xKuEvOhT4AhlRt/3czTSjvGUxjYCBVRQY48ViDHyfYz9VIoBkW4TMGQNapx+l3RUwdA==",
"integrity": "sha1-7dFMgk4sycHgsKG0K7UhBRakJDg=",
"dev": true
},
"lodash.unescape": {
@ -23669,7 +23684,7 @@
"minimist": {
"version": "0.0.8",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
"integrity": "sha512-miQKw5Hv4NS1Psg2517mV4e4dYNaO3++hjAvLOAzKqZ61rH8NS1SK+vbfBWZ5PY/Me/bEWhUwqMghEW5Fb9T7Q=="
"integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0="
}
}
},
@ -23915,40 +23930,170 @@
}
}
},
"mongoose": {
"version": "5.10.9",
"resolved": "https://registry.npmjs.org/mongoose/-/mongoose-5.10.9.tgz",
"integrity": "sha512-7dkr1d6Uyk87hELzoc6B7Zo7kkPTx8rKummk51Y0je2V2Ttsw0KFPwTp1G8JIbBta7Wpw8j15PJi0d33Ode2nw==",
"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.1.4",
"kareem": "2.3.1",
"mongodb": "3.6.2",
"mongoose-legacy-pluralize": "1.0.2",
"mpath": "0.7.0",
"mquery": "3.2.2",
"ms": "2.1.2",
"regexp-clone": "1.0.0",
"safe-buffer": "5.2.1",
"sift": "7.0.1",
"sliced": "1.0.1"
"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": {
"ms": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
"es6-promise": {
"version": "3.2.1",
"resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-3.2.1.tgz",
"integrity": "sha1-7FYjOGgDKQkgcXDDlEjiREndH8Q="
},
"safe-buffer": {
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
"integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ=="
"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-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=="
"mongoose": {
"version": "4.13.19",
"resolved": "https://registry.npmjs.org/mongoose/-/mongoose-4.13.19.tgz",
"integrity": "sha512-O41XmkbAZtLK6Uw4cqjI30s0sP8oZeG+aWweOIyE2VYHMQiYDWhVkBMtsv+Kv8chDizaBhO5oErTHexLQKzU+w==",
"requires": {
"async": "2.6.0",
"bson": "~1.0.4",
"hooks-fixed": "2.0.2",
"kareem": "1.5.0",
"lodash.get": "4.4.2",
"mongodb": "2.2.34",
"mpath": "0.5.1",
"mpromise": "0.5.5",
"mquery": "2.3.3",
"ms": "2.0.0",
"muri": "1.3.0",
"regexp-clone": "0.0.1",
"sliced": "1.0.1"
},
"dependencies": {
"async": {
"version": "2.6.0",
"resolved": "https://registry.npmjs.org/async/-/async-2.6.0.tgz",
"integrity": "sha512-xAfGg1/NTLBBKlHFmnd7PlmUW9KhVQIUuSrYem9xzFUZy13ScvtyGGejaae9iAVRiRq9+Cx7DPFaAAhCpyxyPw==",
"requires": {
"lodash": "^4.14.0"
}
},
"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": "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"
}
}
}
},
"morgan": {
"version": "1.10.0",
@ -24003,39 +24148,43 @@
}
},
"mpath": {
"version": "0.7.0",
"resolved": "https://registry.npmjs.org/mpath/-/mpath-0.7.0.tgz",
"integrity": "sha512-Aiq04hILxhz1L+f7sjGyn7IxYzWm1zLNNXcfhDtx04kZ2Gk7uvFdgZ8ts1cWa/6d0TQmag2yR8zSGZUmp0tFNg=="
"version": "0.5.1",
"resolved": "https://registry.npmjs.org/mpath/-/mpath-0.5.1.tgz",
"integrity": "sha512-H8OVQ+QEz82sch4wbODFOz+3YQ61FYz/z3eJ5pIdbMEaUzDqA268Wd+Vt4Paw9TJfvDgVKaayC0gBzMIw2jhsg=="
},
"mpromise": {
"version": "0.5.5",
"resolved": "https://registry.npmjs.org/mpromise/-/mpromise-0.5.5.tgz",
"integrity": "sha512-b/IJDqWlRXIW3ZouxIkUYLZFrr4qK/oUEgfVAywuvm77nTdDmY6y57lHxA8kfLnOSM+SbAUN/VvU1RxsGBLkQw=="
},
"mquery": {
"version": "3.2.2",
"resolved": "https://registry.npmjs.org/mquery/-/mquery-3.2.2.tgz",
"integrity": "sha512-XB52992COp0KP230I3qloVUbkLUxJIu328HBP2t2EsxSFtf4W1HPSOBWOXf1bqxK4Xbb66lfMJ+Bpfd9/yZE1Q==",
"version": "2.3.3",
"resolved": "https://registry.npmjs.org/mquery/-/mquery-2.3.3.tgz",
"integrity": "sha512-NC8L14kn+qxJbbJ1gbcEMDxF0sC3sv+1cbRReXXwVvowcwY1y9KoVZFq0ebwARibsadu8lx8nWGvm3V0Pf0ZWQ==",
"requires": {
"bluebird": "3.5.1",
"debug": "3.1.0",
"regexp-clone": "^1.0.0",
"safe-buffer": "5.1.2",
"sliced": "1.0.1"
"bluebird": "3.5.0",
"debug": "2.6.9",
"regexp-clone": "0.0.1",
"sliced": "0.0.5"
},
"dependencies": {
"bluebird": {
"version": "3.5.1",
"resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.1.tgz",
"integrity": "sha512-MKiLiV+I1AA596t9w1sQJ8jkiSr5+ZKi0WKrYGUn6d1Fx+Ij4tIj+m2WMQSGczs5jZVxV339chE8iwk6F64wjA=="
"version": "3.5.0",
"resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.0.tgz",
"integrity": "sha512-3LE8m8bqjGdoxfvf71yhFNrUcwy3NLy00SAo+b6MfJ8l+Bc2DzQ7mUHwX6pjK2AxfgV+YfsjCeVW3T5HLQTBsQ=="
},
"debug": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz",
"integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==",
"version": "2.6.9",
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
"requires": {
"ms": "2.0.0"
}
},
"safe-buffer": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="
"sliced": {
"version": "0.0.5",
"resolved": "https://registry.npmjs.org/sliced/-/sliced-0.0.5.tgz",
"integrity": "sha512-9bYT917D6H3+q8GlQBJmLVz3bc4OeVGfZ2BB12wvLnluTGfG6/8UdOUbKJDW1EEx9SZMDbjnatkau5/XcUeyOw=="
}
}
},
@ -24082,6 +24231,11 @@
"integrity": "sha512-cnAsSVxIDsYt0v7HmC0hWZFwwXSh+E6PgCrREDuN/EsjgLwA5XRmlMHhSiDPrt6HxY1gTivEa/Zh7GtODoLevQ==",
"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": {
"version": "0.0.7",
"resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.7.tgz",
@ -24091,7 +24245,7 @@
"mv": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/mv/-/mv-2.1.1.tgz",
"integrity": "sha512-at/ZndSy3xEGJ8i0ygALh8ru9qy7gWW1cmkaqBN29JmMlIvM//MEO9y1sk/avxuwnPcfhkejkLsuPxH81BrkSg==",
"integrity": "sha1-rmzg1vbV4KT32JN5jQPB6pVZtqI=",
"optional": true,
"requires": {
"mkdirp": "~0.5.1",
@ -24102,7 +24256,7 @@
"glob": {
"version": "6.0.4",
"resolved": "https://registry.npmjs.org/glob/-/glob-6.0.4.tgz",
"integrity": "sha512-MKZeRNyYZAVVVG1oZeLaWie1uweH40m9AZwIwxyPbTSX4hHrVYSzLg0Ro5Z5R7XKkIX+Cc6oD1rqeDJnwsB8/A==",
"integrity": "sha1-DwiGD2oVUSey+t1PnOJLGqtuTSI=",
"optional": true,
"requires": {
"inflight": "^1.0.4",
@ -24115,7 +24269,7 @@
"rimraf": {
"version": "2.4.5",
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.4.5.tgz",
"integrity": "sha512-J5xnxTyqaiw06JjMftq7L9ouA448dw/E7dKghkP9WpKNuwmARNNg+Gk8/u5ryb9N/Yo2+z3MCwuqFK/+qPOPfQ==",
"integrity": "sha1-7nEM5dk6j9uFb7Xqj/Di11k0sto=",
"optional": true,
"requires": {
"glob": "^6.0.1"
@ -24173,7 +24327,7 @@
"ncp": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/ncp/-/ncp-2.0.0.tgz",
"integrity": "sha512-zIdGUrPRFTUELUvr3Gmc7KZ2Sw/h1PiVM0Af/oHB6zgnV1ikqSfRk+TOufi79aHYCW3NiOXmr1BP5nWbzojLaA==",
"integrity": "sha1-GVoh1sRuNh0vsSgbo4uR6d9727M=",
"optional": true
},
"needle": {
@ -25897,7 +26051,7 @@
"os-homedir": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz",
"integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M="
"integrity": "sha512-B5JU3cabzk8c67mRRd3ECmROafjYMXbuzlwtqdM8IbS8ktlTix8aFGb2bAGKrSRIlnfKwovGUUr72JUPyOb6kQ=="
},
"os-locale": {
"version": "2.1.0",
@ -26191,6 +26345,11 @@
"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": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/parse-ms/-/parse-ms-2.1.0.tgz",
@ -27671,6 +27830,11 @@
"resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz",
"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": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/progress/-/progress-2.0.0.tgz",
@ -29583,7 +29747,7 @@
"react-prop-types": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/react-prop-types/-/react-prop-types-0.4.0.tgz",
"integrity": "sha512-IyjsJhDX9JkoOV9wlmLaS7z+oxYoIWhfzDcFy7inwoAKTu+VcVNrVpPmLeioJ94y6GeDRsnwarG1py5qofFQMg==",
"integrity": "sha1-+ZsL+0AGkpya8gUefBQUpcdbk9A=",
"requires": {
"warning": "^3.0.0"
}
@ -30239,9 +30403,9 @@
}
},
"regexp-clone": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/regexp-clone/-/regexp-clone-1.0.0.tgz",
"integrity": "sha512-TuAasHQNamyyJ2hb97IuBEif4qBHGjPHBS64sZwytpLEqtBQ1gPJTnOaQ6qmpET16cK14kkjbazl6+p0RRv0yw=="
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/regexp-clone/-/regexp-clone-0.0.1.tgz",
"integrity": "sha512-tfYXF0HXEYh3AtgdjqNLQ8+tmZSAKIS7KtOjmB1laJgfbsi+Lf2RVNwLZVOE3U27yBXikzQuIXglLlakvb8Thw=="
},
"regexp.prototype.flags": {
"version": "1.3.0",
@ -32192,11 +32356,6 @@
}
}
},
"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": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz",
@ -32277,7 +32436,7 @@
"sliced": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/sliced/-/sliced-1.0.1.tgz",
"integrity": "sha1-CzpmK10Ewxd7GSa+qCsD+Dei70E="
"integrity": "sha512-VZBmZP8WU3sMOZm1bdgTadsQbcscK0UM8oKxKVBs4XAhUo2Xxzm/OFMGBkPusxw9xL3Uy8LrzEqGqJhclsr0yA=="
},
"slugify": {
"version": "1.4.0",
@ -33694,7 +33853,7 @@
"stubs": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/stubs/-/stubs-3.0.0.tgz",
"integrity": "sha512-PdHt7hHUJKxvTCgbKX9C1V/ftOcjJQgz8BZwNfV5c4B6dcGqlpelTbJ999jBGZ2jYiPAwcX5dP6oBwVlBlUbxw=="
"integrity": "sha1-6NK6H6nJBXAwPAMLaQD31fiavls="
},
"style-loader": {
"version": "1.2.1",
@ -34588,6 +34747,11 @@
}
}
},
"thunky": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/thunky/-/thunky-0.1.0.tgz",
"integrity": "sha512-vquTt/sKNzFqFK8DKLg33U7deg93WKYH4CE2Ul9hOyMCfm7VXgM7GJQRpPAgnmgnrf407Fcq8TQVEKlbavAu+A=="
},
"timed-out": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/timed-out/-/timed-out-4.0.1.tgz",
@ -34664,10 +34828,15 @@
"resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz",
"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": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/to-no-case/-/to-no-case-1.0.2.tgz",
"integrity": "sha512-Z3g735FxuZY8rodxV4gH7LxClE4H0hTIyHNIHdk+vpQxjLm0cwnKXq/OFVZ76SOQmto7txVcwSCwkU5kqp+FKg=="
"integrity": "sha1-xyKQcWTvaxeBMsjmmTAhLRtKoWo="
},
"to-object-path": {
"version": "0.3.0",
@ -34752,7 +34921,7 @@
"to-snake-case": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/to-snake-case/-/to-snake-case-1.0.0.tgz",
"integrity": "sha512-joRpzBAk1Bhi2eGEYBjukEWHOe/IvclOkiJl3DtA91jV6NwQ3MwXA4FHYeqk8BNp/D8bmi9tcNbRu/SozP0jbQ==",
"integrity": "sha1-znRpE4l5RgGah+Yu366upMYIq4w=",
"requires": {
"to-space-case": "^1.0.0"
}
@ -34760,7 +34929,7 @@
"to-space-case": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/to-space-case/-/to-space-case-1.0.0.tgz",
"integrity": "sha512-rLdvwXZ39VOn1IxGL3V6ZstoTbwLRckQmn/U8ZDLuWwIXNpuZDhQ3AiRUlhTbOXFVE9C+dR51wM0CBDhk31VcA==",
"integrity": "sha1-sFLar7Gysp3HcM6gFj5ewOvJ/Bc=",
"requires": {
"to-no-case": "^1.0.0"
}
@ -35975,7 +36144,7 @@
"warning": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/warning/-/warning-3.0.0.tgz",
"integrity": "sha512-jMBt6pUrKn5I+OGgtQ4YZLdhIeJmObddh6CsibPxyQ5yPZm1XExSyzC1LCNX7BzhxWgiHmizBWJTHJIjMjTQYQ==",
"integrity": "sha1-MuU3fLVy3kqwR1O9+IIcAe1gW3w=",
"requires": {
"loose-envify": "^1.0.0"
}

View file

@ -98,7 +98,8 @@
"mocha": "^6.2.2",
"moment": "^2.24.0",
"mongodb": "^3.6.0",
"mongoose": "^5.10.7",
"mongojs": "2.4.0",
"mongoose": "^4.13.19",
"multer": "git+https://github.com/overleaf/multer.git",
"nocache": "^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() {
beforeEach(function() {
return User.updateOne(
return User.update(
{
_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() {
beforeEach(function() {
return User.updateOne(
return User.update(
{
_id: this.user._id
},
@ -224,7 +224,7 @@ describe('FeatureUpdater.refreshFeatures', function() {
describe('when the user has a v1 plan', function() {
beforeEach(function() {
MockV1Api.setUser(42, { plan_name: 'free' })
return User.updateOne(
return User.update(
{
_id: this.user._id
},
@ -251,7 +251,7 @@ describe('FeatureUpdater.refreshFeatures', function() {
describe('when the user has a v1 plan and bonus features', function() {
beforeEach(function() {
MockV1Api.setUser(42, { plan_name: 'free' })
return User.updateOne(
return User.update(
{
_id: this.user._id
},
@ -327,7 +327,7 @@ describe('FeatureUpdater.refreshFeatures', function() {
describe('when the notifyV1Flag is passed', function() {
beforeEach(function() {
return User.updateOne(
return User.update(
{
_id: this.user._id
},
@ -344,7 +344,7 @@ describe('FeatureUpdater.refreshFeatures', function() {
beforeEach(function() {
const futureDate = new Date()
futureDate.setDate(futureDate.getDate() + 1)
return User.updateOne(
return User.update(
{
_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() {
await expect(User.create({ email: email })).to.be.fulfilled
await expect(User.create({ email: email })).to.be.rejected
await expect(User.countDocuments({ email: email })).to.eventually.equal(1)
await expect(User.count({ email: email })).to.eventually.equal(1)
})
})

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -30,7 +30,7 @@ describe('ReferalAllocator', function() {
this.user_id = 'user-id-123'
this.new_user_id = 'new-user-id-123'
this.FeaturesUpdater.refreshFeatures = sinon.stub().yields()
this.User.updateOne = sinon.stub().callsArgWith(3, null)
this.User.update = sinon.stub().callsArgWith(3, null)
this.User.findOne = sinon
.stub()
.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() {
this.User.updateOne
this.User.update
.calledWith(
{
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() {
this.User.updateOne.called.should.equal(false)
this.User.update.called.should.equal(false)
})
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() {
this.User.updateOne.called.should.equal(false)
this.User.update.called.should.equal(false)
})
it('find the referring users id', function() {

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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