From 0a0d359c4d1ad41c0c08bce8cd41912f7d06dfdc Mon Sep 17 00:00:00 2001 From: Alex Reisner <alex@alexreisner.com> Date: Fri, 30 Jan 2015 12:22:47 -0500 Subject: [PATCH] Allow forcing of query to be street address. --- lib/geocoder/query.rb | 2 +- test/unit/query_test.rb | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/geocoder/query.rb b/lib/geocoder/query.rb index 242ff0e7..61710ef9 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 options[:ip_address] || ip_address? + if !options[:street_address] and (options[:ip_address] or 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 1e731d39..14a707e8 100644 --- a/test/unit/query_test.rb +++ b/test/unit/query_test.rb @@ -57,6 +57,13 @@ class QueryTest < GeocoderTestCase assert_instance_of Geocoder::Lookup::Google, query.lookup end + def test_force_specify_street_address + Geocoder.configure({:lookup => :google, :ip_lookup => :freegeoip}) + query = Geocoder::Query.new("4.1.0.2", {street_address: true}) + assert query.ip_address? + assert_instance_of Geocoder::Lookup::Google, query.lookup + end + def test_force_specify_ip_address_with_ip_lookup query = Geocoder::Query.new("address", {:ip_address => true, :ip_lookup => :google}) assert !query.ip_address? -- GitLab