From affe3eda20544e55c00f5dd7eafce9898f382dda Mon Sep 17 00:00:00 2001 From: Thu Trang Pham <thuutrangpham@gmail.com> Date: Fri, 30 Jan 2015 12:08:19 -0500 Subject: [PATCH] Make ip_address specification in Query#lookup use configured ip_lookup --- lib/geocoder/query.rb | 2 +- test/unit/query_test.rb | 11 ++++------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/lib/geocoder/query.rb b/lib/geocoder/query.rb index 79a99233..242ff0e7 100644 --- a/lib/geocoder/query.rb +++ b/lib/geocoder/query.rb @@ -32,7 +32,7 @@ module Geocoder # appropriate to the Query text. # def lookup - if ip_address? || (options[:ip_lookup] && options[:lookup].nil?) + if options[:ip_address] || ip_address? name = options[:ip_lookup] || Configuration.ip_lookup || Geocoder::Lookup.ip_services.first else name = options[:lookup] || Configuration.lookup || Geocoder::Lookup.street_services.first diff --git a/test/unit/query_test.rb b/test/unit/query_test.rb index 7d3ff7ae..a2a30eac 100644 --- a/test/unit/query_test.rb +++ b/test/unit/query_test.rb @@ -50,13 +50,10 @@ class QueryTest < GeocoderTestCase assert_equal Geocoder::Lookup::Nominatim, query.lookup.class end - def test_force_specify_ip_lookup - query = Geocoder::Query.new("address", :ip_lookup => :baidu_ip) + def test_force_specify_ip_address + Geocoder.configure({:ip_lookup => :google}) + query = Geocoder::Query.new("address", {:ip_address => true}) 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 + assert_equal Geocoder::Lookup::Google, query.lookup.class end end -- GitLab