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

Set config options properly.

If forward and reverse geocoding were both declared and options passed
for both, only the options for the first were being set.
parent fd214c85
No related branches found
No related tags found
No related merge requests found
......@@ -60,10 +60,11 @@ module Geocoder
def geocoder_init(options)
unless geocoder_initialized?
@geocoder_options = options
@geocoder_options = {}
require 'geocoder/orms/active_record'
include Geocoder::Orm::ActiveRecord
end
@geocoder_options.merge! options
end
def geocoder_initialized?
......
......@@ -69,6 +69,18 @@ class GeocoderTest < Test::Unit::TestCase
assert_equal "US", e.country
end
def test_fetch_forward_and_reverse_geocoding_on_same_model
g = GasStation.new("Exxon")
g.address = "404 New St, Middletown, CT"
g.fetch_coordinates
assert_not_nil g.lat
assert_not_nil g.lon
assert_nil g.location
g.fetch_address
assert_not_nil g.location
end
# --- Google ---
......
......@@ -132,6 +132,20 @@ class Party < ActiveRecord::Base
end
end
##
# Forward and reverse geocoded model.
# Should fill in whatever's missing (coords or address).
#
class GasStation < ActiveRecord::Base
geocoded_by :address, :latitude => :lat, :longitude => :lon
reverse_geocoded_by :lat, :lon, :address => :location
def initialize(name)
super()
write_attribute :name, name
end
end
class Test::Unit::TestCase
def venue_params(abbrev)
......
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