Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Return countries with two alpha characters in maxmind

commit 4bca62acbead399b35ae13829887615a2f3a9ea5 1 parent 98d11c0
@josacar josacar authored
View
2  lib/geokit/geocoders/maxmind.rb
@@ -26,7 +26,7 @@ def self.maxmind(ip)
:city => res.city_name,
:state => res.region_name,
:zip => res.postal_code,
- :country_code => res.country_code3
+ :country_code => res.country_code2
)
loc.success = ( res.longitude.kind_of?(Numeric) && res.latitude.kind_of?(Numeric) )
View
6 test/test_maxmind_geocoder.rb
@@ -17,10 +17,11 @@ def test_ip_from_autralia
city.stubs(:city_name).returns('Adelaide')
city.stubs(:region_name).returns('Australia')
city.stubs(:postal_code).returns('')
- city.stubs(:country_code3).returns('AUS')
+ city.stubs(:country_code2).returns('AU')
res = Geokit::Geocoders::MaxmindGeocoder.geocode(@ip)
assert_equal 'Adelaide', res.city
+ assert_equal 'AU', res.country_code
assert_equal true, res.success
assert res.city
end
@@ -35,10 +36,11 @@ def test_ip_from_south_america
city.stubs(:city_name).returns('Canelones')
city.stubs(:region_name).returns('')
city.stubs(:postal_code).returns('')
- city.stubs(:country_code3).returns('URY')
+ city.stubs(:country_code2).returns('UR')
res = Geokit::Geocoders::MaxmindGeocoder.geocode(@ip)
assert_equal 'Canelones', res.city
+ assert_equal 'UR', res.country_code
assert_equal true, res.success
assert res.city
end
Please sign in to comment.
Something went wrong with that request. Please try again.