Merge pull request #8363 from overleaf/jel-affiliation-check

[web] Handle when no affiliation found for redundant subscription check

GitOrigin-RevId: c0e653b944b994c5eafaa2d4f2d54f3cb57d67fa
This commit is contained in:
Timothée Alby 2022-06-14 10:14:10 +02:00 committed by Copybot
parent 343cfe4f06
commit 7794e03dcb
2 changed files with 13 additions and 1 deletions

View file

@ -295,7 +295,7 @@ async function maybeCreateRedundantSubscriptionNotification(userId, email) {
userId
)
const confirmedAffiliation = affiliations.find(a => a.email === email)
if (confirmedAffiliation.licence === 'free') {
if (!confirmedAffiliation || confirmedAffiliation.licence === 'free') {
return
}

View file

@ -928,6 +928,18 @@ describe('UserUpdater', function () {
)
})
it('should not call redundantPersonalSubscription when user is not on a commons license', async function () {
this.InstitutionsAPI.promises.getUserAffiliations.resolves([])
this.SubscriptionLocator.promises.getUserIndividualSubscription.resolves({
planCode: 'personal',
groupPlan: false,
})
await this.UserUpdater.promises.confirmEmail(this.user._id, this.newEmail)
sinon.assert.notCalled(
this.NotificationsBuilder.promises.redundantPersonalSubscription
)
})
describe('with institution licence and subscription', function () {
beforeEach(async function () {
this.affiliation = {