Skip to content
Snippets Groups Projects
Commit d58c35e0 authored by Alex Reisner's avatar Alex Reisner Committed by GitHub
Browse files

Merge pull request #1132 from Hirurg103/master

Now result.country doesn't fail if result is not in a country
parents 2e4f6a20 a596eb22
No related branches found
No related tags found
No related merge requests found
......@@ -25,11 +25,19 @@ module Geocoder::Result
end
def country
address_details['CountryName']
if address_details
address_details['CountryName']
else
""
end
end
def country_code
address_details['CountryNameCode']
if address_details
address_details['CountryNameCode']
else
""
end
end
def state
......
{
"response": {
"GeoObjectCollection": {
"metaDataProperty": {
"GeocoderResponseMetaData": {
"request": "32,43",
"found": "2",
"results": "10",
"Point": {
"pos": "32.000000 43.000000"
}
}
},
"featureMember": [
{
"GeoObject": {
"metaDataProperty": {
"GeocoderMetaData": {
"kind": "hydro",
"text": "Black Sea",
"precision": "other",
"AddressDetails": {
"Locality": {
"Premise": {
"PremiseName": "Black Sea"
}
}
}
}
},
"name": "Black Sea",
"boundedBy": {
"Envelope": {
"lowerCorner": "27.442409 40.908662",
"upperCorner": "41.777787 46.627275"
}
},
"Point": {
"pos": "34.188281 43.229215"
}
}
},
{
"GeoObject": {
"metaDataProperty": {
"GeocoderMetaData": {
"kind": "hydro",
"text": "Black Sea",
"precision": "other",
"AddressDetails": {
"Locality": {
"Premise": {
"PremiseName": "Black Sea"
}
}
}
}
},
"name": "Black Sea",
"boundedBy": {
"Envelope": {
"lowerCorner": "27.628351 40.908893",
"upperCorner": "41.777796 46.627999"
}
},
"Point": {
"pos": "33.383633 44.235582"
}
}
}
]
}
}
}
......@@ -14,4 +14,9 @@ class YandexTest < GeocoderTestCase
result.viewport
end
def test_yandex_empty_results
result = Geocoder.search('black sea').first
assert_equal "", result.country_code
assert_equal "", result.country
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment