diff --git a/services/web/app/src/Features/Subscription/LimitationsManager.js b/services/web/app/src/Features/Subscription/LimitationsManager.js index 6cbc8895b3..4d2e850952 100644 --- a/services/web/app/src/Features/Subscription/LimitationsManager.js +++ b/services/web/app/src/Features/Subscription/LimitationsManager.js @@ -1,16 +1,3 @@ -/* eslint-disable - camelcase, - node/handle-callback-err, - max-len, -*/ -// TODO: This file was created by bulk-decaffeinate. -// Fix any style issues and re-enable lint. -/* - * decaffeinate suggestions: - * DS102: Remove unnecessary code created because of implicit returns - * DS207: Consider shorter variations of null checks - * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md - */ let LimitationsManager const OError = require('@overleaf/o-error') const logger = require('logger-sharelatex') @@ -24,65 +11,62 @@ const V1SubscriptionManager = require('./V1SubscriptionManager') const { V1ConnectionError } = require('../Errors/Errors') module.exports = LimitationsManager = { - allowedNumberOfCollaboratorsInProject(project_id, callback) { - return ProjectGetter.getProject( - project_id, + allowedNumberOfCollaboratorsInProject(projectId, callback) { + ProjectGetter.getProject( + projectId, { owner_ref: true }, (error, project) => { - if (error != null) { + if (error) { return callback(error) } - return this.allowedNumberOfCollaboratorsForUser( - project.owner_ref, - callback - ) + this.allowedNumberOfCollaboratorsForUser(project.owner_ref, callback) } ) }, - allowedNumberOfCollaboratorsForUser(user_id, callback) { - return UserGetter.getUser(user_id, { features: 1 }, function (error, user) { - if (error != null) { + allowedNumberOfCollaboratorsForUser(userId, callback) { + UserGetter.getUser(userId, { features: 1 }, function (error, user) { + if (error) { return callback(error) } - if (user.features != null && user.features.collaborators != null) { - return callback(null, user.features.collaborators) + if (user.features && user.features.collaborators) { + callback(null, user.features.collaborators) } else { - return callback(null, Settings.defaultFeatures.collaborators) + callback(null, Settings.defaultFeatures.collaborators) } }) }, - canAddXCollaborators(project_id, x_collaborators, callback) { - if (callback == null) { + canAddXCollaborators(projectId, numberOfNewCollaborators, callback) { + if (!callback) { callback = function (error, allowed) {} } - return this.allowedNumberOfCollaboratorsInProject( - project_id, - (error, allowed_number) => { - if (error != null) { + this.allowedNumberOfCollaboratorsInProject( + projectId, + (error, allowedNumber) => { + if (error) { return callback(error) } - return CollaboratorsGetter.getInvitedCollaboratorCount( - project_id, - (error, current_number) => { - if (error != null) { + CollaboratorsGetter.getInvitedCollaboratorCount( + projectId, + (error, currentNumber) => { + if (error) { return callback(error) } - return CollaboratorsInvitesHandler.getInviteCount( - project_id, - (error, invite_count) => { - if (error != null) { + CollaboratorsInvitesHandler.getInviteCount( + projectId, + (error, inviteCount) => { + if (error) { return callback(error) } if ( - current_number + invite_count + x_collaborators <= - allowed_number || - allowed_number < 0 + currentNumber + inviteCount + numberOfNewCollaborators <= + allowedNumber || + allowedNumber < 0 ) { - return callback(null, true) + callback(null, true) } else { - return callback(null, false) + callback(null, false) } } ) @@ -93,116 +77,115 @@ module.exports = LimitationsManager = { }, hasPaidSubscription(user, callback) { - if (callback == null) { + if (!callback) { callback = function (err, hasSubscriptionOrIsMember) {} } - return this.userHasV2Subscription( - user, - (err, hasSubscription, subscription) => { - if (err != null) { + this.userHasV2Subscription(user, (err, hasSubscription, subscription) => { + if (err) { + return callback(err) + } + this.userIsMemberOfGroupSubscription(user, (err, isMember) => { + if (err) { return callback(err) } - return this.userIsMemberOfGroupSubscription(user, (err, isMember) => { - if (err != null) { - return callback(err) - } - return this.userHasV1Subscription(user, (err, hasV1Subscription) => { - if (err != null) { - return callback( - new V1ConnectionError( - 'error getting subscription from v1' - ).withCause(err) - ) - } + this.userHasV1Subscription(user, (err, hasV1Subscription) => { + if (err) { return callback( - err, - isMember || hasSubscription || hasV1Subscription, - subscription + new V1ConnectionError( + 'error getting subscription from v1' + ).withCause(err) ) - }) + } + callback( + err, + isMember || hasSubscription || hasV1Subscription, + subscription + ) }) - } - ) + }) + }) }, // alias for backward-compatibility with modules. Use `haspaidsubscription` instead userHasSubscriptionOrIsGroupMember(user, callback) { - return this.hasPaidSubscription(user, callback) + this.hasPaidSubscription(user, callback) }, userHasV2Subscription(user, callback) { - if (callback == null) { + if (!callback) { callback = function (err, hasSubscription, subscription) {} } - return SubscriptionLocator.getUsersSubscription( + SubscriptionLocator.getUsersSubscription( user._id, function (err, subscription) { - if (err != null) { + if (err) { return callback(err) } - const hasValidSubscription = - subscription != null && - (subscription.recurlySubscription_id != null || - (subscription != null ? subscription.customAccount : undefined) === - true) - return callback(err, hasValidSubscription, subscription) + let hasValidSubscription = false + if (subscription) { + if ( + subscription.recurlySubscription_id || + subscription.customAccount + ) { + hasValidSubscription = true + } + } + callback(err, hasValidSubscription, subscription) } ) }, userHasV1OrV2Subscription(user, callback) { - if (callback == null) { + if (!callback) { callback = function (err, hasSubscription) {} } - return this.userHasV2Subscription(user, (err, hasV2Subscription) => { - if (err != null) { + this.userHasV2Subscription(user, (err, hasV2Subscription) => { + if (err) { return callback(err) } if (hasV2Subscription) { return callback(null, true) } - return this.userHasV1Subscription(user, (err, hasV1Subscription) => { - if (err != null) { + this.userHasV1Subscription(user, (err, hasV1Subscription) => { + if (err) { return callback(err) } if (hasV1Subscription) { return callback(null, true) } - return callback(null, false) + callback(null, false) }) }) }, userIsMemberOfGroupSubscription(user, callback) { - if (callback == null) { + if (!callback) { callback = function (error, isMember, subscriptions) {} } - return SubscriptionLocator.getMemberSubscriptions( + SubscriptionLocator.getMemberSubscriptions( user._id, function (err, subscriptions) { - if (subscriptions == null) { + if (!subscriptions) { subscriptions = [] } - if (err != null) { + if (err) { return callback(err) } - return callback(err, subscriptions.length > 0, subscriptions) + callback(err, subscriptions.length > 0, subscriptions) } ) }, userHasV1Subscription(user, callback) { - if (callback == null) { + if (!callback) { callback = function (error, hasV1Subscription) {} } - return V1SubscriptionManager.getSubscriptionsFromV1( + V1SubscriptionManager.getSubscriptionsFromV1( user._id, function (err, v1Subscription) { - return callback( + callback( err, - !!(v1Subscription != null - ? v1Subscription.has_subscription - : undefined) + !!(v1Subscription ? v1Subscription.has_subscription : undefined) ) } ) @@ -218,19 +201,19 @@ module.exports = LimitationsManager = { }, hasGroupMembersLimitReached(subscriptionId, callback) { - if (callback == null) { + if (!callback) { callback = function (err, limitReached, subscription) {} } - return SubscriptionLocator.getSubscription( + SubscriptionLocator.getSubscription( subscriptionId, function (err, subscription) { - if (err != null) { + if (err) { OError.tag(err, 'error getting subscription', { subscriptionId, }) return callback(err) } - if (subscription == null) { + if (!subscription) { logger.warn({ subscriptionId }, 'no subscription found') return callback(new Error('no subscription found')) } @@ -238,7 +221,7 @@ module.exports = LimitationsManager = { const limitReached = LimitationsManager.teamHasReachedMemberLimit( subscription ) - return callback(err, limitReached, subscription) + callback(err, limitReached, subscription) } ) }, diff --git a/services/web/test/unit/src/Subscription/LimitationsManagerTests.js b/services/web/test/unit/src/Subscription/LimitationsManagerTests.js index 9bfa9abaf7..9345543b56 100644 --- a/services/web/test/unit/src/Subscription/LimitationsManagerTests.js +++ b/services/web/test/unit/src/Subscription/LimitationsManagerTests.js @@ -1,17 +1,3 @@ -/* eslint-disable - camelcase, - node/handle-callback-err, - max-len, - no-return-assign, - no-unused-vars, -*/ -// TODO: This file was created by bulk-decaffeinate. -// Fix any style issues and re-enable lint. -/* - * decaffeinate suggestions: - * DS102: Remove unnecessary code created because of implicit returns - * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md - */ const SandboxedModule = require('sandboxed-module') const sinon = require('sinon') const modulePath = require('path').join( @@ -21,23 +7,23 @@ const modulePath = require('path').join( describe('LimitationsManager', function () { beforeEach(function () { - this.project = { _id: (this.project_id = 'project-id') } - this.user = { _id: (this.user_id = 'user-id'), features: {} } + this.project = { _id: (this.projectId = 'project-id') } + this.user = { _id: (this.userId = 'user-id'), features: {} } this.ProjectGetter = { - getProject: (project_id, fields, callback) => { - if (project_id === this.project_id) { - return callback(null, this.project) + getProject: (projectId, fields, callback) => { + if (projectId === this.projectId) { + callback(null, this.project) } else { - return callback(null, null) + callback(null, null) } }, } this.UserGetter = { - getUser: (user_id, filter, callback) => { - if (user_id === this.user_id) { - return callback(null, this.user) + getUser: (userId, filter, callback) => { + if (userId === this.userId) { + callback(null, this.user) } else { - return callback(null, null) + callback(null, null) } }, } @@ -47,7 +33,7 @@ describe('LimitationsManager', function () { getSubscription: sinon.stub(), } - return (this.LimitationsManager = SandboxedModule.require(modulePath, { + this.LimitationsManager = SandboxedModule.require(modulePath, { requires: { '../Project/ProjectGetter': this.ProjectGetter, '../User/UserGetter': this.UserGetter, @@ -57,24 +43,24 @@ describe('LimitationsManager', function () { '../Collaborators/CollaboratorsInviteHandler': (this.CollaboratorsInviteHandler = {}), './V1SubscriptionManager': (this.V1SubscriptionManager = {}), }, - })) + }) }) describe('allowedNumberOfCollaboratorsInProject', function () { describe('when the project is owned by a user without a subscription', function () { beforeEach(function () { this.Settings.defaultFeatures = { collaborators: 23 } - this.project.owner_ref = this.user_id + this.project.owner_ref = this.userId delete this.user.features this.callback = sinon.stub() - return this.LimitationsManager.allowedNumberOfCollaboratorsInProject( - this.project_id, + this.LimitationsManager.allowedNumberOfCollaboratorsInProject( + this.projectId, this.callback ) }) it('should return the default number', function () { - return this.callback + this.callback .calledWith(null, this.Settings.defaultFeatures.collaborators) .should.equal(true) }) @@ -82,17 +68,17 @@ describe('LimitationsManager', function () { describe('when the project is owned by a user with a subscription', function () { beforeEach(function () { - this.project.owner_ref = this.user_id + this.project.owner_ref = this.userId this.user.features = { collaborators: 21 } this.callback = sinon.stub() - return this.LimitationsManager.allowedNumberOfCollaboratorsInProject( - this.project_id, + this.LimitationsManager.allowedNumberOfCollaboratorsInProject( + this.projectId, this.callback ) }) it('should return the number of collaborators the user is allowed', function () { - return this.callback + this.callback .calledWith(null, this.user.features.collaborators) .should.equal(true) }) @@ -105,14 +91,14 @@ describe('LimitationsManager', function () { this.Settings.defaultFeatures = { collaborators: 23 } delete this.user.features this.callback = sinon.stub() - return this.LimitationsManager.allowedNumberOfCollaboratorsForUser( - this.user_id, + this.LimitationsManager.allowedNumberOfCollaboratorsForUser( + this.userId, this.callback ) }) it('should return the default number', function () { - return this.callback + this.callback .calledWith(null, this.Settings.defaultFeatures.collaborators) .should.equal(true) }) @@ -122,14 +108,14 @@ describe('LimitationsManager', function () { beforeEach(function () { this.user.features = { collaborators: 21 } this.callback = sinon.stub() - return this.LimitationsManager.allowedNumberOfCollaboratorsForUser( - this.user_id, + this.LimitationsManager.allowedNumberOfCollaboratorsForUser( + this.userId, this.callback ) }) it('should return the number of collaborators the user is allowed', function () { - return this.callback + this.callback .calledWith(null, this.user.features.collaborators) .should.equal(true) }) @@ -143,11 +129,11 @@ describe('LimitationsManager', function () { this.allowed_number = 2 this.invite_count = 0 this.CollaboratorsGetter.getInvitedCollaboratorCount = ( - project_id, + projectId, callback ) => callback(null, this.current_number) this.CollaboratorsInviteHandler.getInviteCount = ( - project_id, + projectId, callback ) => callback(null, this.invite_count) sinon @@ -155,19 +141,19 @@ describe('LimitationsManager', function () { this.LimitationsManager, 'allowedNumberOfCollaboratorsInProject' ) - .callsFake((project_id, callback) => { - return callback(null, this.allowed_number) + .callsFake((projectId, callback) => { + callback(null, this.allowed_number) }) this.callback = sinon.stub() - return this.LimitationsManager.canAddXCollaborators( - this.project_id, + this.LimitationsManager.canAddXCollaborators( + this.projectId, 1, this.callback ) }) it('should return true', function () { - return this.callback.calledWith(null, true).should.equal(true) + this.callback.calledWith(null, true).should.equal(true) }) }) @@ -177,11 +163,11 @@ describe('LimitationsManager', function () { this.allowed_number = 4 this.invite_count = 1 this.CollaboratorsGetter.getInvitedCollaboratorCount = ( - project_id, + projectId, callback ) => callback(null, this.current_number) this.CollaboratorsInviteHandler.getInviteCount = ( - project_id, + projectId, callback ) => callback(null, this.invite_count) sinon @@ -189,19 +175,19 @@ describe('LimitationsManager', function () { this.LimitationsManager, 'allowedNumberOfCollaboratorsInProject' ) - .callsFake((project_id, callback) => { - return callback(null, this.allowed_number) + .callsFake((projectId, callback) => { + callback(null, this.allowed_number) }) this.callback = sinon.stub() - return this.LimitationsManager.canAddXCollaborators( - this.project_id, + this.LimitationsManager.canAddXCollaborators( + this.projectId, 1, this.callback ) }) it('should return true', function () { - return this.callback.calledWith(null, true).should.equal(true) + this.callback.calledWith(null, true).should.equal(true) }) }) @@ -211,11 +197,11 @@ describe('LimitationsManager', function () { this.allowed_number = 2 this.invite_count = 0 this.CollaboratorsGetter.getInvitedCollaboratorCount = ( - project_id, + projectId, callback ) => callback(null, this.current_number) this.CollaboratorsInviteHandler.getInviteCount = ( - project_id, + projectId, callback ) => callback(null, this.invite_count) sinon @@ -223,19 +209,19 @@ describe('LimitationsManager', function () { this.LimitationsManager, 'allowedNumberOfCollaboratorsInProject' ) - .callsFake((project_id, callback) => { - return callback(null, this.allowed_number) + .callsFake((projectId, callback) => { + callback(null, this.allowed_number) }) this.callback = sinon.stub() - return this.LimitationsManager.canAddXCollaborators( - this.project_id, + this.LimitationsManager.canAddXCollaborators( + this.projectId, 2, this.callback ) }) it('should return false', function () { - return this.callback.calledWith(null, false).should.equal(true) + this.callback.calledWith(null, false).should.equal(true) }) }) @@ -245,11 +231,11 @@ describe('LimitationsManager', function () { this.allowed_number = 2 this.invite_count = 0 this.CollaboratorsGetter.getInvitedCollaboratorCount = ( - project_id, + projectId, callback ) => callback(null, this.current_number) this.CollaboratorsInviteHandler.getInviteCount = ( - project_id, + projectId, callback ) => callback(null, this.invite_count) sinon @@ -257,19 +243,19 @@ describe('LimitationsManager', function () { this.LimitationsManager, 'allowedNumberOfCollaboratorsInProject' ) - .callsFake((project_id, callback) => { - return callback(null, this.allowed_number) + .callsFake((projectId, callback) => { + callback(null, this.allowed_number) }) this.callback = sinon.stub() - return this.LimitationsManager.canAddXCollaborators( - this.project_id, + this.LimitationsManager.canAddXCollaborators( + this.projectId, 1, this.callback ) }) it('should return false', function () { - return this.callback.calledWith(null, false).should.equal(true) + this.callback.calledWith(null, false).should.equal(true) }) }) @@ -279,11 +265,11 @@ describe('LimitationsManager', function () { this.allowed_number = -1 this.invite_count = 0 this.CollaboratorsGetter.getInvitedCollaboratorCount = ( - project_id, + projectId, callback ) => callback(null, this.current_number) this.CollaboratorsInviteHandler.getInviteCount = ( - project_id, + projectId, callback ) => callback(null, this.invite_count) sinon @@ -291,19 +277,19 @@ describe('LimitationsManager', function () { this.LimitationsManager, 'allowedNumberOfCollaboratorsInProject' ) - .callsFake((project_id, callback) => { - return callback(null, this.allowed_number) + .callsFake((projectId, callback) => { + callback(null, this.allowed_number) }) this.callback = sinon.stub() - return this.LimitationsManager.canAddXCollaborators( - this.project_id, + this.LimitationsManager.canAddXCollaborators( + this.projectId, 1, this.callback ) }) it('should return true', function () { - return this.callback.calledWith(null, true).should.equal(true) + this.callback.calledWith(null, true).should.equal(true) }) }) @@ -313,11 +299,11 @@ describe('LimitationsManager', function () { this.allowed_number = 2 this.invite_count = 2 this.CollaboratorsGetter.getInvitedCollaboratorCount = ( - project_id, + projectId, callback ) => callback(null, this.current_number) this.CollaboratorsInviteHandler.getInviteCount = ( - project_id, + projectId, callback ) => callback(null, this.invite_count) sinon @@ -325,19 +311,19 @@ describe('LimitationsManager', function () { this.LimitationsManager, 'allowedNumberOfCollaboratorsInProject' ) - .callsFake((project_id, callback) => { - return callback(null, this.allowed_number) + .callsFake((projectId, callback) => { + callback(null, this.allowed_number) }) this.callback = sinon.stub() - return this.LimitationsManager.canAddXCollaborators( - this.project_id, + this.LimitationsManager.canAddXCollaborators( + this.projectId, 1, this.callback ) }) it('should return false', function () { - return this.callback.calledWith(null, false).should.equal(true) + this.callback.calledWith(null, false).should.equal(true) }) }) @@ -347,11 +333,11 @@ describe('LimitationsManager', function () { this.allowed_number = 2 this.invite_count = 1 this.CollaboratorsGetter.getInvitedCollaboratorCount = ( - project_id, + projectId, callback ) => callback(null, this.current_number) this.CollaboratorsInviteHandler.getInviteCount = ( - project_id, + projectId, callback ) => callback(null, this.invite_count) sinon @@ -359,37 +345,37 @@ describe('LimitationsManager', function () { this.LimitationsManager, 'allowedNumberOfCollaboratorsInProject' ) - .callsFake((project_id, callback) => { - return callback(null, this.allowed_number) + .callsFake((projectId, callback) => { + callback(null, this.allowed_number) }) this.callback = sinon.stub() - return this.LimitationsManager.canAddXCollaborators( - this.project_id, + this.LimitationsManager.canAddXCollaborators( + this.projectId, 1, this.callback ) }) it('should return false', function () { - return this.callback.calledWith(null, false).should.equal(true) + this.callback.calledWith(null, false).should.equal(true) }) }) }) describe('userHasV2Subscription', function () { beforeEach(function () { - return (this.SubscriptionLocator.getUsersSubscription = sinon.stub()) + this.SubscriptionLocator.getUsersSubscription = sinon.stub() }) it('should return true if the recurly token is set', function (done) { this.SubscriptionLocator.getUsersSubscription.callsArgWith(1, null, { recurlySubscription_id: '1234', }) - return this.LimitationsManager.userHasV2Subscription( + this.LimitationsManager.userHasV2Subscription( this.user, (err, hasSubscription) => { hasSubscription.should.equal(true) - return done() + done() } ) }) @@ -397,22 +383,22 @@ describe('LimitationsManager', function () { it('should return false if the recurly token is not set', function (done) { this.SubscriptionLocator.getUsersSubscription.callsArgWith(1, null, {}) this.subscription = {} - return this.LimitationsManager.userHasV2Subscription( + this.LimitationsManager.userHasV2Subscription( this.user, (err, hasSubscription) => { hasSubscription.should.equal(false) - return done() + done() } ) }) it('should return false if the subscription is undefined', function (done) { this.SubscriptionLocator.getUsersSubscription.callsArgWith(1) - return this.LimitationsManager.userHasV2Subscription( + this.LimitationsManager.userHasV2Subscription( this.user, (err, hasSubscription) => { hasSubscription.should.equal(false) - return done() + done() } ) }) @@ -424,11 +410,11 @@ describe('LimitationsManager', function () { null, stubbedSubscription ) - return this.LimitationsManager.userHasV2Subscription( + this.LimitationsManager.userHasV2Subscription( this.user, (err, hasSubOrIsGroupMember, subscription) => { subscription.should.deep.equal(stubbedSubscription) - return done() + done() } ) }) @@ -436,7 +422,7 @@ describe('LimitationsManager', function () { describe('when user has a custom account', function () { beforeEach(function () { this.fakeSubscription = { customAccount: true } - return this.SubscriptionLocator.getUsersSubscription.callsArgWith( + this.SubscriptionLocator.getUsersSubscription.callsArgWith( 1, null, this.fakeSubscription @@ -444,21 +430,21 @@ describe('LimitationsManager', function () { }) it('should return true', function (done) { - return this.LimitationsManager.userHasV2Subscription( + this.LimitationsManager.userHasV2Subscription( this.user, (err, hasSubscription, subscription) => { hasSubscription.should.equal(true) - return done() + done() } ) }) it('should return the subscription', function (done) { - return this.LimitationsManager.userHasV2Subscription( + this.LimitationsManager.userHasV2Subscription( this.user, (err, hasSubscription, subscription) => { subscription.should.deep.equal(this.fakeSubscription) - return done() + done() } ) }) @@ -467,16 +453,16 @@ describe('LimitationsManager', function () { describe('userIsMemberOfGroupSubscription', function () { beforeEach(function () { - return (this.SubscriptionLocator.getMemberSubscriptions = sinon.stub()) + this.SubscriptionLocator.getMemberSubscriptions = sinon.stub() }) it('should return false if there are no groups subcriptions', function (done) { this.SubscriptionLocator.getMemberSubscriptions.callsArgWith(1, null, []) - return this.LimitationsManager.userIsMemberOfGroupSubscription( + this.LimitationsManager.userIsMemberOfGroupSubscription( this.user, (err, isMember) => { isMember.should.equal(false) - return done() + done() } ) }) @@ -488,12 +474,12 @@ describe('LimitationsManager', function () { null, (subscriptions = ['mock-subscription']) ) - return this.LimitationsManager.userIsMemberOfGroupSubscription( + this.LimitationsManager.userIsMemberOfGroupSubscription( this.user, (err, isMember, retSubscriptions) => { isMember.should.equal(true) retSubscriptions.should.equal(subscriptions) - return done() + done() } ) }) @@ -507,20 +493,20 @@ describe('LimitationsManager', function () { this.LimitationsManager.userHasV2Subscription = sinon .stub() .yields(null, false) - return (this.LimitationsManager.userHasV1Subscription = sinon + this.LimitationsManager.userHasV1Subscription = sinon .stub() - .yields(null, false)) + .yields(null, false) }) it('should return true if userIsMemberOfGroupSubscription', function (done) { this.LimitationsManager.userIsMemberOfGroupSubscription = sinon .stub() .yields(null, true) - return this.LimitationsManager.hasPaidSubscription( + this.LimitationsManager.hasPaidSubscription( this.user, (err, hasSubOrIsGroupMember) => { hasSubOrIsGroupMember.should.equal(true) - return done() + done() } ) }) @@ -529,11 +515,11 @@ describe('LimitationsManager', function () { this.LimitationsManager.userHasV2Subscription = sinon .stub() .yields(null, true) - return this.LimitationsManager.hasPaidSubscription( + this.LimitationsManager.hasPaidSubscription( this.user, (err, hasSubOrIsGroupMember) => { hasSubOrIsGroupMember.should.equal(true) - return done() + done() } ) }) @@ -542,31 +528,31 @@ describe('LimitationsManager', function () { this.LimitationsManager.userHasV1Subscription = sinon .stub() .yields(null, true) - return this.LimitationsManager.hasPaidSubscription( + this.LimitationsManager.hasPaidSubscription( this.user, (err, hasSubOrIsGroupMember) => { hasSubOrIsGroupMember.should.equal(true) - return done() + done() } ) }) it('should return false if none are true', function (done) { - return this.LimitationsManager.hasPaidSubscription( + this.LimitationsManager.hasPaidSubscription( this.user, (err, hasSubOrIsGroupMember) => { hasSubOrIsGroupMember.should.equal(false) - return done() + done() } ) }) it('should have userHasSubscriptionOrIsGroupMember alias', function (done) { - return this.LimitationsManager.userHasSubscriptionOrIsGroupMember( + this.LimitationsManager.userHasSubscriptionOrIsGroupMember( this.user, (err, hasSubOrIsGroupMember) => { hasSubOrIsGroupMember.should.equal(false) - return done() + done() } ) }) @@ -577,20 +563,20 @@ describe('LimitationsManager', function () { this.LimitationsManager.userHasV2Subscription = sinon .stub() .yields(null, false) - return (this.LimitationsManager.userHasV1Subscription = sinon + this.LimitationsManager.userHasV1Subscription = sinon .stub() - .yields(null, false)) + .yields(null, false) }) it('should return true if userHasV2Subscription', function (done) { this.LimitationsManager.userHasV2Subscription = sinon .stub() .yields(null, true) - return this.LimitationsManager.userHasV1OrV2Subscription( + this.LimitationsManager.userHasV1OrV2Subscription( this.user, (err, hasSub) => { hasSub.should.equal(true) - return done() + done() } ) }) @@ -599,21 +585,21 @@ describe('LimitationsManager', function () { this.LimitationsManager.userHasV1Subscription = sinon .stub() .yields(null, true) - return this.LimitationsManager.userHasV1OrV2Subscription( + this.LimitationsManager.userHasV1OrV2Subscription( this.user, (err, hasSub) => { hasSub.should.equal(true) - return done() + done() } ) }) it('should return false if none are true', function (done) { - return this.LimitationsManager.userHasV1OrV2Subscription( + this.LimitationsManager.userHasV1OrV2Subscription( this.user, (err, hasSub) => { hasSub.should.equal(false) - return done() + done() } ) }) @@ -622,13 +608,13 @@ describe('LimitationsManager', function () { describe('hasGroupMembersLimitReached', function () { beforeEach(function () { this.subscriptionId = '12312' - return (this.subscription = { + this.subscription = { membersLimit: 3, member_ids: ['', ''], teamInvites: [ { email: 'bob@example.com', sentAt: new Date(), token: 'hey' }, ], - }) + } }) it('should return true if the limit is hit (including members and invites)', function (done) { @@ -637,11 +623,11 @@ describe('LimitationsManager', function () { null, this.subscription ) - return this.LimitationsManager.hasGroupMembersLimitReached( + this.LimitationsManager.hasGroupMembersLimitReached( this.subscriptionId, (err, limitReached) => { limitReached.should.equal(true) - return done() + done() } ) }) @@ -653,11 +639,11 @@ describe('LimitationsManager', function () { null, this.subscription ) - return this.LimitationsManager.hasGroupMembersLimitReached( + this.LimitationsManager.hasGroupMembersLimitReached( this.subscriptionId, (err, limitReached) => { limitReached.should.equal(false) - return done() + done() } ) }) @@ -669,11 +655,11 @@ describe('LimitationsManager', function () { null, this.subscription ) - return this.LimitationsManager.hasGroupMembersLimitReached( + this.LimitationsManager.hasGroupMembersLimitReached( this.subscriptionId, (err, limitReached) => { limitReached.should.equal(true) - return done() + done() } ) }) @@ -684,14 +670,14 @@ describe('LimitationsManager', function () { this.V1SubscriptionManager.getSubscriptionsFromV1 = sinon .stub() .yields(null, { has_subscription: true }) - return this.LimitationsManager.userHasV1Subscription( + this.LimitationsManager.userHasV1Subscription( this.user, (error, result) => { this.V1SubscriptionManager.getSubscriptionsFromV1 - .calledWith(this.user_id) + .calledWith(this.userId) .should.equal(true) result.should.equal(true) - return done() + done() } ) }) @@ -700,14 +686,14 @@ describe('LimitationsManager', function () { this.V1SubscriptionManager.getSubscriptionsFromV1 = sinon .stub() .yields(null, { has_subscription: false }) - return this.LimitationsManager.userHasV1Subscription( + this.LimitationsManager.userHasV1Subscription( this.user, (error, result) => { this.V1SubscriptionManager.getSubscriptionsFromV1 - .calledWith(this.user_id) + .calledWith(this.userId) .should.equal(true) result.should.equal(false) - return done() + done() } ) }) @@ -716,14 +702,14 @@ describe('LimitationsManager', function () { this.V1SubscriptionManager.getSubscriptionsFromV1 = sinon .stub() .yields(null, null) - return this.LimitationsManager.userHasV1Subscription( + this.LimitationsManager.userHasV1Subscription( this.user, (error, result) => { this.V1SubscriptionManager.getSubscriptionsFromV1 - .calledWith(this.user_id) + .calledWith(this.userId) .should.equal(true) result.should.equal(false) - return done() + done() } ) })