Skip to content

Commit

Permalink
Return countries with two alpha characters in maxmind
Browse files Browse the repository at this point in the history
  • Loading branch information
josacar committed Dec 12, 2013
1 parent 98d11c0 commit 4bca62a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/geokit/geocoders/maxmind.rb
Expand Up @@ -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) )
Expand Down
6 changes: 4 additions & 2 deletions test/test_maxmind_geocoder.rb
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 4bca62a

Please sign in to comment.