Implement checks for user eligibility when switching plans (#24276)
* Convert updateSubscription controller to async/await * Move updateSubscription to subscription module * Validate if user is eligible to change plan GitOrigin-RevId: ce538429cd5a3b93acabdc046f1a8b164ac02301
This commit is contained in:
@@ -175,9 +175,9 @@ describe('SubscriptionController', function () {
|
||||
recordEventForSession: sinon.stub(),
|
||||
setUserPropertyForUser: sinon.stub(),
|
||||
}),
|
||||
'../../infrastructure/Modules': {
|
||||
'../../infrastructure/Modules': (this.Modules = {
|
||||
promises: { hooks: { fire: sinon.stub().resolves() } },
|
||||
},
|
||||
}),
|
||||
'../../infrastructure/Features': this.Features,
|
||||
'../../util/currency': (this.currency = {
|
||||
formatCurrency: sinon.stub(),
|
||||
@@ -293,32 +293,6 @@ describe('SubscriptionController', function () {
|
||||
})
|
||||
})
|
||||
|
||||
describe('updateSubscription via post', function () {
|
||||
beforeEach(function (done) {
|
||||
this.res = {
|
||||
redirect() {
|
||||
done()
|
||||
},
|
||||
}
|
||||
sinon.spy(this.res, 'redirect')
|
||||
this.plan_code = '1234'
|
||||
this.req.body.plan_code = this.plan_code
|
||||
this.SubscriptionController.updateSubscription(this.req, this.res)
|
||||
})
|
||||
|
||||
it('should send the user and subscriptionId to the handler', function (done) {
|
||||
this.SubscriptionHandler.updateSubscription
|
||||
.calledWith(this.user, this.plan_code)
|
||||
.should.equal(true)
|
||||
done()
|
||||
})
|
||||
|
||||
it('should redurect to the subscription page', function (done) {
|
||||
this.res.redirect.calledWith('/user/subscription').should.equal(true)
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
describe('updateAccountEmailAddress via put', function () {
|
||||
it('should send the user and subscriptionId to RecurlyWrapper', function () {
|
||||
this.res.sendStatus = sinon.spy()
|
||||
|
||||
Reference in New Issue
Block a user