mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #3355 from overleaf/jpa-use-count-again
[misc] mongodb: use deprecated db.collection.count again GitOrigin-RevId: 93dc05651747ca49b0e26547a330682f85ad9cef
This commit is contained in:
parent
87634be542
commit
654abb3b47
3 changed files with 6 additions and 9 deletions
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
})
|
||||
})
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ describe('CollaboratorsInviteHandler', function() {
|
|||
this.findOne = sinon.stub()
|
||||
this.find = sinon.stub()
|
||||
this.deleteOne = sinon.stub()
|
||||
this.countDocuments = 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) {
|
||||
|
|
Loading…
Reference in a new issue