diff --git a/services/web/app/coffee/infrastructure/GeoIpLookup.coffee b/services/web/app/coffee/infrastructure/GeoIpLookup.coffee index 07fb041721..54b8c89731 100644 --- a/services/web/app/coffee/infrastructure/GeoIpLookup.coffee +++ b/services/web/app/coffee/infrastructure/GeoIpLookup.coffee @@ -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) \ No newline at end of file diff --git a/services/web/test/UnitTests/coffee/infrastructure/GeoIpLookupTests.coffee b/services/web/test/UnitTests/coffee/infrastructure/GeoIpLookupTests.coffee index 590c5cbf27..8f8f559d09 100644 --- a/services/web/test/UnitTests/coffee/infrastructure/GeoIpLookupTests.coffee +++ b/services/web/test/UnitTests/coffee/infrastructure/GeoIpLookupTests.coffee @@ -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()