Merge pull request #4672 from overleaf/sk-validate-currency-param

Subscription: validate currency in query param
GitOrigin-RevId: 0c9f841ba56b5ce85bbd2adeb3fb2d45d0ad753a
This commit is contained in:
June Kelly
2021-08-25 08:03:20 +00:00
committed by Copybot
parent ea161174fe
commit 8aeb782791
4 changed files with 40 additions and 3 deletions
@@ -108,6 +108,7 @@ describe('SubscriptionController', function () {
gaExperiments: {},
}
this.GeoIpLookup = {
isValidCurrencyParam: sinon.stub().returns(true),
getCurrencyCode: sinon.stub(),
promises: {
getCurrencyCode: sinon.stub(),
@@ -263,6 +264,16 @@ describe('SubscriptionController', function () {
}
this.SubscriptionController.paymentPage(this.req, this.res)
})
it('should use the geo ip currency if not valid', function (done) {
this.req.query.currency = 'WAT'
this.GeoIpLookup.isValidCurrencyParam.returns(false)
this.res.render = (page, opts) => {
opts.currency.should.equal(this.stubbedCurrencyCode)
done()
}
this.SubscriptionController.paymentPage(this.req, this.res)
})
})
describe('with a recurly subscription already', function () {