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

Also accept Google components as a string.

parent afa3f63f
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.join("|") params[:components] = components.is_a?(Array) ? components.join("|") : components
end end
params params
end end
......
...@@ -65,7 +65,17 @@ class ServicesTest < Test::Unit::TestCase ...@@ -65,7 +65,17 @@ class ServicesTest < Test::Unit::TestCase
assert_match /region=gb/, url assert_match /region=gb/, url
end end
def test_google_query_url_contains_properly_formatted_components def test_google_query_url_contains_components_when_given_as_string
lookup = Geocoder::Lookup::Google.new
url = lookup.send(:query_url, Geocoder::Query.new(
"Some Intersection",
:components => "locality:ES"
))
formatted = "components=" + CGI.escape("locality:ES")
assert url.include?(formatted), "Expected #{formatted} to be included in #{url}"
end
def test_google_query_url_contains_components_when_given_as_array
lookup = Geocoder::Lookup::Google.new lookup = Geocoder::Lookup::Google.new
url = lookup.send(:query_url, Geocoder::Query.new( url = lookup.send(:query_url, Geocoder::Query.new(
"Some Intersection", "Some Intersection",
......
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