mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
default to USD if there is no match
This commit is contained in:
parent
4a774981cf
commit
19a08f82a6
2 changed files with 8 additions and 1 deletions
|
@ -39,6 +39,6 @@ module.exports = GeoIpLookup =
|
|||
logger.err err:err, ip:ip, "problem getting currencyCode for ip, defaulting to USD"
|
||||
return callback(null, "USD")
|
||||
countryCode = ipDetails?.country_code?.toUpperCase()
|
||||
currencyCode = currencyMappings[countryCode]
|
||||
currencyCode = currencyMappings[countryCode] || "USD"
|
||||
logger.log ip:ip, currencyCode:currencyCode, ipDetails:ipDetails, "got currencyCode for ip"
|
||||
callback(err, currencyCode)
|
|
@ -96,3 +96,10 @@ describe "GeoIpLookup", ->
|
|||
@GeoIpLookup.getCurrencyCode @ipAddress, (err, currencyCode)->
|
||||
currencyCode.should.equal "USD"
|
||||
done()
|
||||
|
||||
it "should default to USD if there is no match for their country", (done)->
|
||||
@stubbedResponse.country_code = "Non existant"
|
||||
@GeoIpLookup.getDetails = sinon.stub().callsArgWith(1, null, @stubbedResponse)
|
||||
@GeoIpLookup.getCurrencyCode @ipAddress, (err, currencyCode)->
|
||||
currencyCode.should.equal "USD"
|
||||
done()
|
||||
|
|
Loading…
Reference in a new issue