From c1d80657c93dce725616242ad51f97182f3c4718 Mon Sep 17 00:00:00 2001 From: Aaron Parecki <aaron@parecki.com> Date: Wed, 25 May 2016 15:37:33 -0700 Subject: [PATCH] add `source_country` parameter for esri geocoder --- lib/geocoder/lookups/esri.rb | 1 + test/unit/lookups/esri_test.rb | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/lib/geocoder/lookups/esri.rb b/lib/geocoder/lookups/esri.rb index a8afb0a2..c634f1a9 100644 --- a/lib/geocoder/lookups/esri.rb +++ b/lib/geocoder/lookups/esri.rb @@ -44,6 +44,7 @@ module Geocoder::Lookup end params[:token] = token params[:forStorage] = configuration[:for_storage] if configuration[:for_storage] + params[:sourceCountry] = configuration[:source_country] if configuration[:source_country] params.merge(super) end diff --git a/test/unit/lookups/esri_test.rb b/test/unit/lookups/esri_test.rb index bd6486fa..a14ac8a5 100644 --- a/test/unit/lookups/esri_test.rb +++ b/test/unit/lookups/esri_test.rb @@ -16,6 +16,14 @@ class EsriTest < GeocoderTestCase res end + def test_query_for_geocode_with_source_country + Geocoder.configure(esri: {source_country: 'USA'}) + query = Geocoder::Query.new("Bluffton, SC") + lookup = Geocoder::Lookup.get(:esri) + url = lookup.query_url(query) + assert_match /sourceCountry=USA/, url + end + def test_query_for_geocode_with_token_and_for_storage token = Geocoder::EsriToken.new('xxxxx', Time.now + 1.day) Geocoder.configure(esri: {token: token, for_storage: true}) -- GitLab