|
@@ -344,12 +344,27 @@ describe('TeamInvitesHandler', function () {
|
|
|
email: 'tyrion@example.com',
|
|
email: 'tyrion@example.com',
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ this.user_subscription = {
|
|
|
|
|
+ id: '66264b9125930b976cc0811e',
|
|
|
|
|
+ _id: new ObjectId('66264b9125930b976cc0811e'),
|
|
|
|
|
+ groupPlan: false,
|
|
|
|
|
+ recurlySubscription_id: 'fa1b2cfa156gh',
|
|
|
|
|
+ admin_id: '123456789',
|
|
|
|
|
+ member_ids: [],
|
|
|
|
|
+ teamInvites: [],
|
|
|
|
|
+ save: sinon.stub().resolves(),
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
this.ipAddress = '127.0.0.1'
|
|
this.ipAddress = '127.0.0.1'
|
|
|
|
|
|
|
|
this.UserGetter.promises.getUserByAnyEmail
|
|
this.UserGetter.promises.getUserByAnyEmail
|
|
|
.withArgs(this.user.email)
|
|
.withArgs(this.user.email)
|
|
|
.resolves(this.user)
|
|
.resolves(this.user)
|
|
|
|
|
|
|
|
|
|
+ this.SubscriptionLocator.promises.getUsersSubscription
|
|
|
|
|
+ .withArgs(this.user.id)
|
|
|
|
|
+ .resolves(this.user_subscription)
|
|
|
|
|
+
|
|
|
this.subscription.teamInvites.push({
|
|
this.subscription.teamInvites.push({
|
|
|
email: 'john.snow@example.com',
|
|
email: 'john.snow@example.com',
|
|
|
token: 'dddddddd',
|
|
token: 'dddddddd',
|
|
@@ -421,12 +436,12 @@ describe('TeamInvitesHandler', function () {
|
|
|
)
|
|
)
|
|
|
sinon.assert.calledWith(
|
|
sinon.assert.calledWith(
|
|
|
this.SubscriptionUpdater.promises.deleteSubscription,
|
|
this.SubscriptionUpdater.promises.deleteSubscription,
|
|
|
- this.subscription,
|
|
|
|
|
|
|
+ this.user_subscription,
|
|
|
{ id: this.user.id, ip: this.ipAddress }
|
|
{ id: this.user.id, ip: this.ipAddress }
|
|
|
)
|
|
)
|
|
|
sinon.assert.calledWith(
|
|
sinon.assert.calledWith(
|
|
|
this.RecurlyClient.promises.terminateSubscriptionByUuid,
|
|
this.RecurlyClient.promises.terminateSubscriptionByUuid,
|
|
|
- this.subscription.recurlySubscription_id
|
|
|
|
|
|
|
+ this.user_subscription.recurlySubscription_id
|
|
|
)
|
|
)
|
|
|
sinon.assert.calledWith(
|
|
sinon.assert.calledWith(
|
|
|
this.Modules.promises.hooks.fire,
|
|
this.Modules.promises.hooks.fire,
|
|
@@ -435,6 +450,23 @@ describe('TeamInvitesHandler', function () {
|
|
|
this.subscription
|
|
this.subscription
|
|
|
)
|
|
)
|
|
|
})
|
|
})
|
|
|
|
|
+
|
|
|
|
|
+ it('should not delete the users subscription if that subscription is also the join target', async function () {
|
|
|
|
|
+ this.subscription.managedUsersEnabled = true
|
|
|
|
|
+ this.SubscriptionLocator.promises.getUsersSubscription
|
|
|
|
|
+ .withArgs(this.user.id)
|
|
|
|
|
+ .resolves(this.subscription)
|
|
|
|
|
+
|
|
|
|
|
+ await this.TeamInvitesHandler.promises.acceptInvite(
|
|
|
|
|
+ 'dddddddd',
|
|
|
|
|
+ this.user.id,
|
|
|
|
|
+ this.ipAddress
|
|
|
|
|
+ )
|
|
|
|
|
+
|
|
|
|
|
+ sinon.assert.notCalled(
|
|
|
|
|
+ this.SubscriptionUpdater.promises.deleteSubscription
|
|
|
|
|
+ )
|
|
|
|
|
+ })
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
describe('with group SSO enabled', function () {
|
|
describe('with group SSO enabled', function () {
|