Skip to content
Snippets Groups Projects
Commit 6a0c2490 authored by Thu Trang Pham's avatar Thu Trang Pham
Browse files

Force specfify ip_lookup on search, even when ip_address? fails

parent 1a60d20b
No related branches found
No related tags found
No related merge requests found
...@@ -32,7 +32,7 @@ module Geocoder ...@@ -32,7 +32,7 @@ module Geocoder
# appropriate to the Query text. # appropriate to the Query text.
# #
def lookup def lookup
if ip_address? if ip_address? || (options[:ip_lookup] && options[:lookup].nil?)
name = options[:ip_lookup] || Configuration.ip_lookup || Geocoder::Lookup.ip_services.first name = options[:ip_lookup] || Configuration.ip_lookup || Geocoder::Lookup.ip_services.first
else else
name = options[:lookup] || Configuration.lookup || Geocoder::Lookup.street_services.first name = options[:lookup] || Configuration.lookup || Geocoder::Lookup.street_services.first
......
...@@ -49,4 +49,14 @@ class QueryTest < GeocoderTestCase ...@@ -49,4 +49,14 @@ class QueryTest < GeocoderTestCase
query = Geocoder::Query.new("address", :lookup => :nominatim) query = Geocoder::Query.new("address", :lookup => :nominatim)
assert_equal Geocoder::Lookup::Nominatim, query.lookup.class assert_equal Geocoder::Lookup::Nominatim, query.lookup.class
end end
def test_force_specify_ip_lookup
query = Geocoder::Query.new("address", :ip_lookup => :baidu_ip)
assert !query.ip_address?
assert_equal Geocoder::Lookup::BaiduIp, query.lookup.class
query = Geocoder::Query.new("address", :ip_lookup => :baidu_ip, :lookup => :bing)
assert !query.ip_address?
assert_equal Geocoder::Lookup::Bing, query.lookup.class
end
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