diff --git a/lib/geocoder/query.rb b/lib/geocoder/query.rb index 3da86ef17430b0227dcc9a8cf285a97835197551..d4d93b1aaf2a230469cf6f0fd257472a9979d816 100644 --- a/lib/geocoder/query.rb +++ b/lib/geocoder/query.rb @@ -40,7 +40,13 @@ module Geocoder # Is the Query text blank? (ie, should we not bother searching?) # def blank? - !!text.to_s.match(/^\s*$/) + # check whether both coordinates given + if text.is_a?(Array) + text.compact.size < 2 + # else assume a string + else + !!text.to_s.match(/^\s*$/) + end end ## diff --git a/test/query_test.rb b/test/query_test.rb index 22a90b5c674d181f7815b19e6949c4ea87d66c80..fada72ad19336bfa9d135cf018adbe375bfdd285 100644 --- a/test/query_test.rb +++ b/test/query_test.rb @@ -20,6 +20,11 @@ class QueryTest < Test::Unit::TestCase assert !Geocoder::Query.new("МоÑква").blank? # no ASCII characters end + def test_blank_query_detection_for_coordinates + assert Geocoder::Query.new([nil,nil]).blank? + assert Geocoder::Query.new([87,nil]).blank? + end + def test_coordinates_detection assert Geocoder::Query.new("51.178844,5").coordinates? assert Geocoder::Query.new("51.178844, -1.826189").coordinates?