diff --git a/lib/geokit/geocoders/ca_geocoder.rb b/lib/geokit/geocoders/ca_geocoder.rb index 731174cb..01f63a91 100644 --- a/lib/geokit/geocoders/ca_geocoder.rb +++ b/lib/geokit/geocoders/ca_geocoder.rb @@ -35,7 +35,8 @@ def self.parse_xml(xml, loc) # Formats the request in the format acceptable by the CA geocoder. def self.submit_url(loc) - args = ["locate=#{Geokit::Inflector.url_escape(loc)}"] + loc_str = loc.is_a?(GeoLoc) ? loc.to_geocodeable_s : loc + args = ["locate=#{Geokit::Inflector.url_escape(loc_str)}"] args << "auth=#{key}" if key args << 'geoit=xml' 'http://geocoder.ca/?' + args.join('&') diff --git a/test/test_ca_geocoder.rb b/test/test_ca_geocoder.rb index f926b41e..fe00a050 100644 --- a/test/test_ca_geocoder.rb +++ b/test/test_ca_geocoder.rb @@ -31,6 +31,14 @@ def test_service_unavailable assert !geocode(@ca_full_txt).success end + def test_geocoder_with_geo_loc_object + response = MockSuccess.new + response.expects(:body).returns(CA_SUCCESS) + url = 'http://geocoder.ca/?locate=2105+West+32nd+Avenue%2C+Vancouver%2C+BC&auth=SOMEKEYVALUE&geoit=xml' + geocoder_class.expects(:call_geocoder_service).with(url).returns(response) + verify(geocode(Geokit::GeoLoc.new(@ca_full_hash))) + end + private def verify(location)