소스 검색

Merge pull request #2651 from overleaf/ta-missing-return

Add Missing Return

GitOrigin-RevId: aeb622a6745678eb687217beeb49b5d023168052
nate stemen 6 년 전
부모
커밋
6379f15815

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

@@ -206,7 +206,7 @@ module.exports = SubscriptionController = {
       }
       }
       if (hasSubscription) {
       if (hasSubscription) {
         logger.warn({ user_id: user._id }, 'user already has subscription')
         logger.warn({ user_id: user._id }, 'user already has subscription')
-        res.sendStatus(409) // conflict
+        return res.sendStatus(409) // conflict
       }
       }
       return SubscriptionHandler.createSubscription(
       return SubscriptionHandler.createSubscription(
         user,
         user,

+ 12 - 0
services/web/test/unit/src/Subscription/SubscriptionControllerTests.js

@@ -419,6 +419,18 @@ describe('SubscriptionController', function() {
   })
   })
 
 
   describe('createSubscription with errors', function() {
   describe('createSubscription with errors', function() {
+    it('should handle users with subscription', function(done) {
+      this.LimitationsManager.userHasV1OrV2Subscription.yields(null, true)
+      this.SubscriptionController.createSubscription(this.req, {
+        sendStatus: status => {
+          expect(status).to.equal(409)
+          this.SubscriptionHandler.createSubscription.called.should.equal(false)
+
+          done()
+        }
+      })
+    })
+
     it('should handle 3DSecure errors', function(done) {
     it('should handle 3DSecure errors', function(done) {
       this.next = sinon.stub()
       this.next = sinon.stub()
       this.LimitationsManager.userHasV1OrV2Subscription.yields(null, false)
       this.LimitationsManager.userHasV1OrV2Subscription.yields(null, false)