diff --git a/lib/geokit/geocoders/maxmind.rb b/lib/geokit/geocoders/maxmind.rb index a036cb54..43fc0103 100644 --- a/lib/geokit/geocoders/maxmind.rb +++ b/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) ) diff --git a/test/test_maxmind_geocoder.rb b/test/test_maxmind_geocoder.rb index f44dec81..4352cba5 100644 --- a/test/test_maxmind_geocoder.rb +++ b/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