diff --git a/services/web/app/src/Features/Subscription/SubscriptionController.js b/services/web/app/src/Features/Subscription/SubscriptionController.js index ff6e5dee0e..87664f914d 100644 --- a/services/web/app/src/Features/Subscription/SubscriptionController.js +++ b/services/web/app/src/Features/Subscription/SubscriptionController.js @@ -206,7 +206,7 @@ module.exports = SubscriptionController = { } if (hasSubscription) { logger.warn({ user_id: user._id }, 'user already has subscription') - res.sendStatus(409) // conflict + return res.sendStatus(409) // conflict } return SubscriptionHandler.createSubscription( user, diff --git a/services/web/test/unit/src/Subscription/SubscriptionControllerTests.js b/services/web/test/unit/src/Subscription/SubscriptionControllerTests.js index a768655559..6a660582b7 100644 --- a/services/web/test/unit/src/Subscription/SubscriptionControllerTests.js +++ b/services/web/test/unit/src/Subscription/SubscriptionControllerTests.js @@ -419,6 +419,18 @@ describe('SubscriptionController', 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) { this.next = sinon.stub() this.LimitationsManager.userHasV1OrV2Subscription.yields(null, false)