فهرست منبع

Merge pull request #25289 from overleaf/kh-rm-dead-coupon-code

[web] rm unused couponCode parameter

GitOrigin-RevId: c8c262322d74214e43870e67758aaa98aaa60c79
M Fahru 1 سال پیش
والد
کامیت
fa553128a4

+ 1 - 14
services/web/app/src/Features/Subscription/SubscriptionHandler.js

@@ -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
   )

+ 3 - 57
services/web/test/unit/src/Subscription/SubscriptionHandlerTests.js

@@ -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 () {