diff --git a/lib/geocoder.rb b/lib/geocoder.rb index b9306ccd5d01aaab8380cee19264488d19438412..4eee5874584118d5bf5685572defb3ac76851fe2 100644 --- a/lib/geocoder.rb +++ b/lib/geocoder.rb @@ -131,7 +131,7 @@ module Geocoder # Is the given search query blank? (ie, should we not bother searching?) # def blank_query?(value) - !value.to_s.match(/[A-z0-9]/) + !!value.to_s.match(/^\s*$/) end end diff --git a/test/geocoder_test.rb b/test/geocoder_test.rb index 9649a9a8081ef6279d98ce4e64e669880b1a3fe5..5443e64a83100cd733f433b86616f178fbfbe65e 100644 --- a/test/geocoder_test.rb +++ b/test/geocoder_test.rb @@ -1,3 +1,4 @@ +# encoding: utf-8 require 'test_helper' class GeocoderTest < Test::Unit::TestCase @@ -213,8 +214,9 @@ class GeocoderTest < Test::Unit::TestCase def test_blank_query_detection assert Geocoder.send(:blank_query?, nil) assert Geocoder.send(:blank_query?, "") - assert Geocoder.send(:blank_query?, ", , (-)") + assert Geocoder.send(:blank_query?, "\t ") assert !Geocoder.send(:blank_query?, "a") + assert !Geocoder.send(:blank_query?, "МоÑква") # no ASCII characters end def test_does_not_choke_on_nil_address