Skip to content
Snippets Groups Projects
Commit 069917c0 authored by Alex Reisner's avatar Alex Reisner
Browse files

Don't overwrite existing config when setting token.

parent 720174d1
No related branches found
No related tags found
No related merge requests found
......@@ -52,7 +52,7 @@ module Geocoder::Lookup
configuration[:token].to_s
elsif configuration.api_key # generate a new token if we have credentials
token_instance = Geocoder::EsriToken.generate_token(*configuration.api_key)
Geocoder.configure(:esri => {:token => token_instance})
Geocoder.configure(:esri => Geocoder.config[:esri].merge({:token => token_instance}))
token_instance.to_s
end
end
......
......@@ -16,14 +16,14 @@ class EsriTest < GeocoderTestCase
res
end
def test_query_for_geocode_with_token_for_storage
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})
query = Geocoder::Query.new("Bluffton, SC")
lookup = Geocoder::Lookup.get(:esri)
res = lookup.query_url(query)
assert_equal "http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/find?f=pjson&forStorage=true&outFields=%2A&text=Bluffton%2C+SC&token=xxxxx",
res
url = lookup.query_url(query)
assert_match /forStorage=true/, url
assert_match /token=xxxxx/, url
end
def test_query_for_reverse_geocode
......
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