trabajo-afectivo/test/integration/geo_location_test.rb

107 lines
3 KiB
Ruby
Raw Normal View History

# encoding: utf-8
require 'integration_test_helper'
class GeoLocationTest < ActiveSupport::TestCase
# check
test 'check simple results' do
result = Service::GeoLocation.geocode('Marienstrasse 13, 10117 Berlin')
assert(result)
2016-08-17 22:29:09 +00:00
assert_equal(52.5219143, result[0])
2016-08-17 22:45:16 +00:00
assert_equal(13.3832647, result[1])
result = Service::GeoLocation.geocode('Marienstrasse 13 10117 Berlin')
assert(result)
2016-08-17 22:45:16 +00:00
assert_equal(52.5219143, result[0])
assert_equal(13.3832647, result[1])
result = Service::GeoLocation.geocode('Martinsbruggstrasse 35, 9016 St. Gallen')
assert(result)
assert_equal(47.4366557, result[0])
assert_equal(9.4098904, result[1])
result = Service::GeoLocation.geocode('Martinsbruggstrasse 35 9016 St. Gallen')
assert(result)
assert_equal(47.4366557, result[0])
assert_equal(9.4098904, result[1])
end
test 'check user results' do
user1 = User.create(
login: 'some_geo_login1',
firstname: 'First',
lastname: 'Last',
email: 'some_geo_login1@example.com',
password: 'test',
address: 'Marienstrasse 13 10117 Berlin',
active: false,
updated_by_id: 1,
created_by_id: 1
)
assert(user1.preferences)
assert(user1.preferences['lat'])
assert(user1.preferences['lng'])
2016-08-17 22:29:09 +00:00
assert_equal(52.5219143, user1.preferences['lat'])
2016-08-17 22:45:16 +00:00
assert_equal(13.3832647, user1.preferences['lng'])
user2 = User.create(
login: 'some_geo_login2',
firstname: 'First',
lastname: 'Last',
email: 'some_geo_login2@example.com',
password: 'test',
street: 'Marienstrasse 13',
city: 'Berlin',
zip: '10117',
active: false,
updated_by_id: 1,
created_by_id: 1
)
assert(user2.preferences)
assert(user2.preferences['lat'])
assert(user2.preferences['lng'])
2016-08-17 22:45:16 +00:00
assert_equal(52.5219143, user2.preferences['lat'])
assert_equal(13.3832647, user2.preferences['lng'])
user3 = User.create(
login: 'some_geo_login3',
firstname: 'First',
lastname: 'Last',
email: 'some_geo_login3@example.com',
password: 'test',
address: 'Martinsbruggstrasse 35, 9016 St. Gallen',
active: false,
updated_by_id: 1,
created_by_id: 1
)
assert(user3.preferences)
assert(user3.preferences['lat'])
assert(user3.preferences['lng'])
assert_equal(47.4366557, user3.preferences['lat'])
assert_equal(9.4098904, user3.preferences['lng'])
user4 = User.create(
login: 'some_geo_login4',
firstname: 'First',
lastname: 'Last',
email: 'some_geo_login4@example.com',
password: 'test',
street: 'Martinsbruggstrasse 35',
city: 'St. Gallen',
zip: '9016',
active: false,
updated_by_id: 1,
created_by_id: 1
)
assert(user4.preferences)
assert(user4.preferences['lat'])
assert(user4.preferences['lng'])
assert_equal(47.4366557, user4.preferences['lat'])
assert_equal(9.4098904, user4.preferences['lng'])
end
end