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

Pass components to Google lookup as array.

parent 1f6ba96d
No related branches found
No related tags found
No related merge requests found
...@@ -44,7 +44,7 @@ module Geocoder::Lookup ...@@ -44,7 +44,7 @@ module Geocoder::Lookup
params[:region] = region params[:region] = region
end end
unless (components = query.options[:components]).nil? unless (components = query.options[:components]).nil?
params[:components] = components params[:components] = components.join("|")
end end
params params
end end
......
...@@ -56,6 +56,25 @@ class ServicesTest < Test::Unit::TestCase ...@@ -56,6 +56,25 @@ class ServicesTest < Test::Unit::TestCase
assert_match /bounds=40.0+%2C-120.0+%7C39.0+%2C-121.0+/, url assert_match /bounds=40.0+%2C-120.0+%7C39.0+%2C-121.0+/, url
end end
def test_google_query_url_contains_region
lookup = Geocoder::Lookup::Google.new
url = lookup.send(:query_url, Geocoder::Query.new(
"Some Intersection",
:region => "gb"
))
assert_match /region=gb/, url
end
def test_google_query_url_contains_properly_formatted_components
lookup = Geocoder::Lookup::Google.new
url = lookup.send(:query_url, Geocoder::Query.new(
"Some Intersection",
:components => ["country:ES", "locality:ES"]
))
formatted = "components=" + CGI.escape("country:ES|locality:ES")
assert url.include?(formatted), "Expected #{formatted} to be included in #{url}"
end
# --- Google Premier --- # --- Google Premier ---
def test_google_premier_result_components def test_google_premier_result_components
......
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