mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-02 21:59:00 +02:00
Merge pull request #25372 from overleaf/kh-support-canceling-pending-stripe-change
[web] cancel pending Stripe subscription change GitOrigin-RevId: c1d21a7d1c3962c20d589b1dd10f6c2a4c8e4be4
This commit is contained in:
@@ -123,8 +123,9 @@ async function cancelPendingSubscriptionChange(user) {
|
||||
await LimitationsManager.promises.userHasSubscription(user)
|
||||
|
||||
if (hasSubscription && subscription != null) {
|
||||
await RecurlyClient.promises.removeSubscriptionChangeByUuid(
|
||||
subscription.recurlySubscription_id
|
||||
await Modules.promises.hooks.fire(
|
||||
'cancelPendingPaidSubscriptionChange',
|
||||
subscription
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -319,6 +319,48 @@ describe('SubscriptionHandler', function () {
|
||||
})
|
||||
})
|
||||
|
||||
describe('cancelPendingSubscriptionChange', function () {
|
||||
beforeEach(function () {
|
||||
this.user.id = this.activeRecurlySubscription.account.account_code
|
||||
this.User.findById = (userId, projection) => ({
|
||||
exec: () => {
|
||||
userId.should.equal(this.user.id)
|
||||
return Promise.resolve(this.user)
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
it('should not fire cancelPendingPaidSubscriptionChange hook if user has no subscription', async function () {
|
||||
this.LimitationsManager.promises.userHasSubscription.resolves({
|
||||
hasSubscription: false,
|
||||
subscription: null,
|
||||
})
|
||||
await this.SubscriptionHandler.promises.cancelPendingSubscriptionChange(
|
||||
this.user,
|
||||
this.plan_code
|
||||
)
|
||||
expect(this.Modules.promises.hooks.fire).to.not.have.been.calledWith(
|
||||
'cancelPendingPaidSubscriptionChange',
|
||||
sinon.match.any
|
||||
)
|
||||
})
|
||||
|
||||
it('should fire cancelPendingPaidSubscriptionChange to update a valid subscription', async function () {
|
||||
this.LimitationsManager.promises.userHasSubscription.resolves({
|
||||
hasSubscription: true,
|
||||
subscription: this.subscription,
|
||||
})
|
||||
await this.SubscriptionHandler.promises.cancelPendingSubscriptionChange(
|
||||
this.user,
|
||||
this.plan_code
|
||||
)
|
||||
expect(this.Modules.promises.hooks.fire).to.have.been.calledWith(
|
||||
'cancelPendingPaidSubscriptionChange',
|
||||
this.subscription
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe('cancelSubscription', function () {
|
||||
describe('with a user without a subscription', function () {
|
||||
beforeEach(async function () {
|
||||
|
||||
Reference in New Issue
Block a user