Les tests liés au geocoding sont vraiment stubbés
This commit is contained in:
parent
7fdfb9f1ec
commit
1144ae5d82
@ -20,7 +20,7 @@ class Event < ActiveRecord::Base
|
||||
validates :submitter, email: true
|
||||
validates :tags, presence: false, format: /\A[\p{Alnum}\s-]*\z/
|
||||
|
||||
geocoded_by :full_address, lookup: :nominatim
|
||||
geocoded_by :full_address
|
||||
# after_validation :geocode, if: -> (obj) { obj.address_changed? }
|
||||
after_validation :geocode
|
||||
|
||||
|
6
config/initializers/geocoder.rb
Normal file
6
config/initializers/geocoder.rb
Normal file
@ -0,0 +1,6 @@
|
||||
Geocoder.configure(
|
||||
# geocoding options
|
||||
# timeout: 3, # geocoding service timeout (secs)
|
||||
lookup: :nominatim, # name of geocoding service (symbol)
|
||||
language: :fr # ISO-639 language code
|
||||
)
|
@ -4,18 +4,6 @@ require 'test_helper'
|
||||
class EventTest < ActiveSupport::TestCase
|
||||
setup do
|
||||
@event = events :one
|
||||
|
||||
Geocoder.configure lookup: :test
|
||||
|
||||
Geocoder::Lookup::Test.set_default_stub [{
|
||||
'latitude' => 40.7143528,
|
||||
'longitude' => -74.0059731,
|
||||
'address' => 'New York, NY, USA',
|
||||
'state' => 'New York',
|
||||
'state_code' => 'NY',
|
||||
'country' => 'United States',
|
||||
'country_code' => 'US'
|
||||
}]
|
||||
end
|
||||
|
||||
test 'basic event' do
|
||||
@ -109,8 +97,8 @@ class EventTest < ActiveSupport::TestCase
|
||||
|
||||
assert @event.valid?, @event.errors.messages
|
||||
assert @event.save
|
||||
assert_nil @event.latitude
|
||||
assert_nil @event.longitude
|
||||
assert_equal 40.7143528, @event.latitude
|
||||
assert_equal(-74.0059731, @event.longitude)
|
||||
end
|
||||
|
||||
test 'json transform' do
|
||||
|
@ -20,5 +20,17 @@ module ActiveSupport
|
||||
fixtures :all
|
||||
|
||||
# Add more helper methods to be used by all tests here...
|
||||
|
||||
Geocoder.configure lookup: :test
|
||||
|
||||
Geocoder::Lookup::Test.set_default_stub [{
|
||||
'latitude' => 40.7143528,
|
||||
'longitude' => -74.0059731,
|
||||
'address' => 'New York, NY, USA',
|
||||
'state' => 'New York',
|
||||
'state_code' => 'NY',
|
||||
'country' => 'United States',
|
||||
'country_code' => 'US'
|
||||
}]
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user