use first ip passed though in string for ip lookup

This commit is contained in:
Henry Oswald 2014-10-13 13:04:20 +01:00
parent 259871cbdd
commit e78e4d46b0
2 changed files with 10 additions and 0 deletions

View file

@ -18,6 +18,11 @@ _.each EuroCountries, (country)-> currencyMappings[country] = "EUR"
module.exports = GeoIpLookup =
getDetails : (ip, callback)->
if !ip?
e = new Error("no ip passed")
return callback(e)
ip = ip.trim().split(" ")[0]
opts =
url: "#{settings.apis.geoIpLookup.url}/#{ip}"
request.get opts, (err, ipDetails)->

View file

@ -49,6 +49,11 @@ describe "GeoIpLookup", ->
assert.deepEqual returnedDetails, @stubbedResponse
done()
it "should take the first ip in the string", (done)->
@GeoIpLookup.getDetails " #{@ipAddress} 456.312.452.102 432.433.888.234", (err)=>
@request.get.calledWith(url:@settings.apis.geoIpLookup.url+"/"+@ipAddress).should.equal true
done()
describe "getCurrencyCode", ->
it "should return GBP for GB country", (done)->