citizenlabsgr / adopt-a-drain

Deploy an Adopt-a-Drain program for the Grand River watershed.
https://lgrow-staging.herokuapp.com
BSD 3-Clause "New" or "Revised" License
2 stars 2 forks source link

add geokit-rails gem update tests #190

Closed Wilfongjt closed 5 years ago

Wilfongjt commented 5 years ago

New Google Map/Geocoder API KEY?

Google has changed the domain for geocoding to “maps.googleapis.com” (https://maps.googleapis.com/maps/api/geocode/json). I believe this is what broke “find drain.” I’ve updated the tests with the new domain name and got a new personal api_key and everything runs locally.

Problem

Travis reports that I should be using the old geocoder domain... “maps.google.com”

Best Guess

I’m guessing that the old domain name is dependent on the old api_key and that is why Travis is suggesting that I go back to the old domain name.

Proposed Solution

Wilfongjt commented 5 years ago

Switched back to https://maps.google.com/maps/api/geocode/json

Running:

......................E.................................

Finished in 9.067878s, 6.1756 runs/s, 21.3942 assertions/s.

1) Error: AddressesControllerTest#test_should_return_latitude_and_longitude_for_a_valid_address: WebMock::NetConnectNotAllowedError: Real HTTP connections are disabled. Unregistered request: GET https://maps.googleapis.com/maps/api/geocode/json?address=City%20Hall,%20Grand%20Rapids,%20MI&key=AIzaSyATwQgdWJVJyJgSWpN1dlIqQbTy4FOZeqU&sensor=false with headers {'Accept'=>'/', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Ruby'}

You can stub this request with the following snippet:

stub_request(:get, "https://maps.googleapis.com/maps/api/geocode/json?address=City%20Hall,%20Grand%20Rapids,%20MI&key=AIzaSyATwQgdWJVJyJgSWpN1dlIqQbTy4FOZeqU&sensor=false"). with( headers: { 'Accept'=>'/', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Ruby' }). to_return(status: 200, body: "", headers: {})

registered request stubs:

stub_request(:get, "https://maps.google.com/maps/api/geocode/json?address=City%20Hall%2C%20Grand%20Rapids%2C%20MI&key=AIzaSyATwQgdWJVJyJgSWpN1dlIqQbTy4FOZeqU&sensor=false")

============================================================ app/models/address.rb:5:in geocode' app/controllers/addresses_controller.rb:5:inshow' test/controllers/addresses_controller_test.rb:10:in `block in '

56 runs, 194 assertions, 0 failures, 1 errors, 0 skips

Wilfongjt commented 5 years ago

Dropping the key in the call

the error recommends using the api key as a query parameter

Running:

............................E...........................

Finished in 6.837444s, 8.1902 runs/s, 28.3732 assertions/s.

1) Error: AddressesControllerTest#test_should_return_latitude_and_longitude_for_a_valid_address: WebMock::NetConnectNotAllowedError: Real HTTP connections are disabled. Unregistered request: GET https://maps.googleapis.com/maps/api/geocode/json?address=City%20Hall,%20Grand%20Rapids,%20MI&key=AIzaSyATwQgdWJVJyJgSWpN1dlIqQbTy4FOZeqU&sensor=false with headers {'Accept'=>'/', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Ruby'}

You can stub this request with the following snippet:

stub_request(:get, "https://maps.googleapis.com/maps/api/geocode/json?address=City%20Hall,%20Grand%20Rapids,%20MI& key=AIzaSyATwQgdWJVJyJgSWpN1dlIqQbTy4FOZeqU &sensor=false"). with( headers: { 'Accept'=>'/', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Ruby' }). to_return(status: 200, body: "", headers: {})

registered request stubs:

stub_request(:get, "https://maps.googleapis.com/maps/api/geocode/json?address=City%20Hall%2C%20Grand%20Rapids%2C%20MI&sensor=false")

============================================================ app/models/address.rb:5:in geocode' app/controllers/addresses_controller.rb:5:inshow' test/controllers/addresses_controller_test.rb:10:in `block in '