mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-23 17:19:37 +02:00
Merge pull request #25289 from overleaf/kh-rm-dead-coupon-code
[web] rm unused couponCode parameter GitOrigin-RevId: c8c262322d74214e43870e67758aaa98aaa60c79
This commit is contained in:
@@ -83,9 +83,8 @@ async function previewSubscriptionChange(userId, planCode) {
|
||||
/**
|
||||
* @param user
|
||||
* @param planCode
|
||||
* @param couponCode
|
||||
*/
|
||||
async function updateSubscription(user, planCode, couponCode) {
|
||||
async function updateSubscription(user, planCode) {
|
||||
let hasSubscription = false
|
||||
let subscription
|
||||
|
||||
@@ -108,18 +107,6 @@ async function updateSubscription(user, planCode, couponCode) {
|
||||
}
|
||||
const recurlySubscriptionId = subscription.recurlySubscription_id
|
||||
|
||||
if (couponCode) {
|
||||
const usersSubscription = await RecurlyWrapper.promises.getSubscription(
|
||||
recurlySubscriptionId,
|
||||
{ includeAccount: true }
|
||||
)
|
||||
|
||||
await RecurlyWrapper.promises.redeemCoupon(
|
||||
usersSubscription.account.account_code,
|
||||
couponCode
|
||||
)
|
||||
}
|
||||
|
||||
const recurlySubscription = await RecurlyClient.promises.getSubscription(
|
||||
recurlySubscriptionId
|
||||
)
|
||||
|
||||
@@ -274,8 +274,7 @@ describe('SubscriptionHandler', function () {
|
||||
})
|
||||
await this.SubscriptionHandler.promises.updateSubscription(
|
||||
this.user,
|
||||
this.plan_code,
|
||||
null
|
||||
this.plan_code
|
||||
)
|
||||
})
|
||||
|
||||
@@ -324,8 +323,7 @@ describe('SubscriptionHandler', function () {
|
||||
expect(
|
||||
this.SubscriptionHandler.promises.updateSubscription(
|
||||
this.user,
|
||||
'unknown-plan',
|
||||
null
|
||||
'unknown-plan'
|
||||
)
|
||||
).to.be.rejected
|
||||
this.RecurlyClient.promises.applySubscriptionChangeRequest.called.should.equal(
|
||||
@@ -339,8 +337,7 @@ describe('SubscriptionHandler', function () {
|
||||
this.LimitationsManager.promises.userHasSubscription.resolves(false)
|
||||
await this.SubscriptionHandler.promises.updateSubscription(
|
||||
this.user,
|
||||
this.plan_code,
|
||||
null
|
||||
this.plan_code
|
||||
)
|
||||
})
|
||||
|
||||
@@ -353,57 +350,6 @@ describe('SubscriptionHandler', function () {
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe('with a coupon code', function () {
|
||||
beforeEach(async 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)
|
||||
},
|
||||
})
|
||||
this.plan_code = 'collaborator'
|
||||
this.coupon_code = '1231312'
|
||||
this.LimitationsManager.promises.userHasSubscription.resolves({
|
||||
hasSubscription: true,
|
||||
subscription: this.subscription,
|
||||
})
|
||||
await this.SubscriptionHandler.promises.updateSubscription(
|
||||
this.user,
|
||||
this.plan_code,
|
||||
this.coupon_code
|
||||
)
|
||||
})
|
||||
|
||||
it('should get the users account', function () {
|
||||
this.RecurlyWrapper.promises.getSubscription
|
||||
.calledWith(this.activeRecurlySubscription.uuid)
|
||||
.should.equal(true)
|
||||
})
|
||||
|
||||
it('should redeem the coupon', function () {
|
||||
this.RecurlyWrapper.promises.redeemCoupon
|
||||
.calledWith(
|
||||
this.activeRecurlySubscription.account.account_code,
|
||||
this.coupon_code
|
||||
)
|
||||
.should.equal(true)
|
||||
})
|
||||
|
||||
it('should update the subscription', function () {
|
||||
expect(
|
||||
this.RecurlyClient.promises.applySubscriptionChangeRequest
|
||||
).to.be.calledWith(
|
||||
new PaymentProviderSubscriptionChangeRequest({
|
||||
subscription: this.activeRecurlyClientSubscription,
|
||||
timeframe: 'now',
|
||||
planCode: this.plan_code,
|
||||
})
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('cancelSubscription', function () {
|
||||
|
||||
Reference in New Issue
Block a user