Moved to new wording to access external services.
This commit is contained in:
parent
326e007481
commit
ae4f48a954
20 changed files with 356 additions and 219 deletions
|
@ -17,8 +17,8 @@ class System extends App.ControllerTabs
|
|||
@title 'System', true
|
||||
@tabs = [
|
||||
{ name: 'Base', 'target': 'base', controller: App.SettingsArea, params: { area: 'System::Base' } },
|
||||
{ name: 'Services', 'target': 'services', controller: App.SettingsArea, params: { area: 'System::Services' } },
|
||||
{ name: 'Storage', 'target': 'storage', controller: App.SettingsArea, params: { area: 'System::Storage' } },
|
||||
{ name: 'Geo Services', 'target': 'geo', controller: App.SettingsArea, params: { area: 'System::Geo' } },
|
||||
{ name: 'Frontend', 'target': 'ui', controller: App.SettingsArea, params: { area: 'System::UI' } },
|
||||
]
|
||||
@render()
|
||||
|
@ -65,7 +65,7 @@ class Ticket extends App.ControllerTabs
|
|||
|
||||
App.Config.set( 'SettingBranding', { prio: 1200, parent: '#settings', name: 'Branding', target: '#settings/branding', controller: Branding, role: ['Admin'] }, 'NavBarAdmin' )
|
||||
App.Config.set( 'SettingSystem', { prio: 1400, parent: '#settings', name: 'System', target: '#settings/system', controller: System, role: ['Admin'] }, 'NavBarAdmin' )
|
||||
App.Config.set( 'SettingSecurity', { prio: 1500, parent: '#settings', name: 'Security', target: '#settings/security', controller: Security, role: ['Admin'] }, 'NavBarAdmin' )
|
||||
App.Config.set( 'SettingTicket', { prio: 1600, parent: '#settings', name: 'Ticket', target: '#settings/ticket', controller: Ticket, role: ['Admin'] }, 'NavBarAdmin' )
|
||||
App.Config.set( 'SettingImport', { prio: 1700, parent: '#settings', name: 'Import', target: '#settings/import', controller: Import, role: ['Admin'] }, 'NavBarAdmin' )
|
||||
App.Config.set( 'SettingSecurity', { prio: 1600, parent: '#settings', name: 'Security', target: '#settings/security', controller: Security, role: ['Admin'] }, 'NavBarAdmin' )
|
||||
App.Config.set( 'SettingTicket', { prio: 1700, parent: '#settings', name: 'Ticket', target: '#settings/ticket', controller: Ticket, role: ['Admin'] }, 'NavBarAdmin' )
|
||||
App.Config.set( 'SettingImport', { prio: 1800, parent: '#settings', name: 'Import', target: '#settings/import', controller: Import, role: ['Admin'] }, 'NavBarAdmin' )
|
||||
|
||||
|
|
|
@ -86,7 +86,7 @@ class ApplicationController < ActionController::Base
|
|||
# check if remote ip need to be updated
|
||||
if !session[:remote_id] || session[:remote_id] != request.remote_ip
|
||||
session[:remote_id] = request.remote_ip
|
||||
session[:geo] = GeoIp.location( request.remote_ip )
|
||||
session[:geo] = Service::GeoIp.location( request.remote_ip )
|
||||
end
|
||||
|
||||
# fill user agent
|
||||
|
|
|
@ -130,7 +130,7 @@ class UsersController < ApplicationController
|
|||
|
||||
# fetch org logo
|
||||
if user.email
|
||||
Zammad::BigData::Organization.suggest_system_image(user.email)
|
||||
Service::Image.organization_suggest(user.email)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -146,7 +146,7 @@ add a avatar
|
|||
end
|
||||
|
||||
# fetch image
|
||||
image = Zammad::BigData::User.image(data[:url])
|
||||
image = Service::Image.user(data[:url])
|
||||
return if !image
|
||||
if !data[:resize]
|
||||
data[:resize] = {}
|
||||
|
|
|
@ -54,7 +54,7 @@ class Observer::User::Geo < ActiveRecord::Observer
|
|||
return if address == ''
|
||||
|
||||
# lookup
|
||||
latlng = GeoLocation.geocode( address )
|
||||
latlng = Service::GeoLocation.geocode( address )
|
||||
return if !latlng
|
||||
|
||||
# store data
|
||||
|
|
76
db/migrate/20150715000001_update_services.rb
Normal file
76
db/migrate/20150715000001_update_services.rb
Normal file
|
@ -0,0 +1,76 @@
|
|||
class UpdateServices < ActiveRecord::Migration
|
||||
def up
|
||||
|
||||
Setting.create_or_update(
|
||||
title: 'Image Service',
|
||||
name: 'image_backend',
|
||||
area: 'System::Services',
|
||||
description: 'Defines the backend for user and organization image lookups.',
|
||||
options: {
|
||||
form: [
|
||||
{
|
||||
display: '',
|
||||
null: true,
|
||||
name: 'image_backend',
|
||||
tag: 'select',
|
||||
options: {
|
||||
'' => '-',
|
||||
'Service::Image::Zammad' => 'Zammad Image Service',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
state: 'Service::Image::Zammad',
|
||||
preferences: { prio: 1 },
|
||||
frontend: false
|
||||
)
|
||||
|
||||
Setting.create_or_update(
|
||||
title: 'Geo IP Service',
|
||||
name: 'geo_ip_backend',
|
||||
area: 'System::Services',
|
||||
description: 'Defines the backend for geo IP lookups. Show also location of an IP address if an IP address is shown.',
|
||||
options: {
|
||||
form: [
|
||||
{
|
||||
display: '',
|
||||
null: true,
|
||||
name: 'geo_ip_backend',
|
||||
tag: 'select',
|
||||
options: {
|
||||
'' => '-',
|
||||
'Service::GeoIp::Zammad' => 'Zammad GeoIP Service',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
state: 'Service::GeoIp::Zammad',
|
||||
preferences: { prio: 2 },
|
||||
frontend: false
|
||||
)
|
||||
|
||||
Setting.create_or_update(
|
||||
title: 'Geo Location Service',
|
||||
name: 'geo_location_backend',
|
||||
area: 'System::Services',
|
||||
description: 'Defines the backend for geo location lookups to store geo locations for addresses.',
|
||||
options: {
|
||||
form: [
|
||||
{
|
||||
display: '',
|
||||
null: true,
|
||||
name: 'geo_location_backend',
|
||||
tag: 'select',
|
||||
options: {
|
||||
'' => '-',
|
||||
'Service::GeoLocation::Gmaps' => 'Google Maps',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
state: 'Service::GeoLocation::Gmaps',
|
||||
preferences: { prio: 3 },
|
||||
frontend: false
|
||||
)
|
||||
end
|
||||
end
|
54
db/seeds.rb
54
db/seeds.rb
|
@ -49,7 +49,7 @@ Setting.create_if_not_exists(
|
|||
],
|
||||
},
|
||||
preferences: { render: true, session_check: true, prio: 1 },
|
||||
state: 'Zammad',
|
||||
state: 'Zammad Helpdesk',
|
||||
frontend: true
|
||||
)
|
||||
Setting.create_if_not_exists(
|
||||
|
@ -196,33 +196,36 @@ Setting.create_if_not_exists(
|
|||
state: 'DB',
|
||||
frontend: false
|
||||
)
|
||||
|
||||
Setting.create_if_not_exists(
|
||||
title: 'Geo Location Backend',
|
||||
name: 'geo_location_backend',
|
||||
area: 'System::Geo',
|
||||
description: 'Defines the backend for geo location lookups.',
|
||||
title: 'Image Service',
|
||||
name: 'image_backend',
|
||||
area: 'System::Services',
|
||||
description: 'Defines the backend for user and organization image lookups.',
|
||||
options: {
|
||||
form: [
|
||||
{
|
||||
display: '',
|
||||
null: true,
|
||||
name: 'geo_location_backend',
|
||||
name: 'image_backend',
|
||||
tag: 'select',
|
||||
options: {
|
||||
'' => '-',
|
||||
'GeoLocation::Gmaps' => 'Google Maps',
|
||||
'Service::Image::Zammad' => 'Zammad Image Service',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
state: 'GeoLocation::Gmaps',
|
||||
state: 'Service::Image::Zammad',
|
||||
preferences: { prio: 1 },
|
||||
frontend: false
|
||||
)
|
||||
|
||||
Setting.create_if_not_exists(
|
||||
title: 'Geo IP Backend',
|
||||
title: 'Geo IP Service',
|
||||
name: 'geo_ip_backend',
|
||||
area: 'System::Geo',
|
||||
description: 'Defines the backend for geo ip lookups.',
|
||||
area: 'System::Services',
|
||||
description: 'Defines the backend for geo IP lookups. Show also location of an IP address if an IP address is shown.',
|
||||
options: {
|
||||
form: [
|
||||
{
|
||||
|
@ -232,12 +235,37 @@ Setting.create_if_not_exists(
|
|||
tag: 'select',
|
||||
options: {
|
||||
'' => '-',
|
||||
'GeoIp::ZammadGeoIp' => 'Zammad GeoIP Service',
|
||||
'Service::GeoIp::Zammad' => 'Zammad GeoIP Service',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
state: 'GeoIp::ZammadGeoIp',
|
||||
state: 'Service::GeoIp::Zammad',
|
||||
preferences: { prio: 2 },
|
||||
frontend: false
|
||||
)
|
||||
|
||||
Setting.create_if_not_exists(
|
||||
title: 'Geo Location Service',
|
||||
name: 'geo_location_backend',
|
||||
area: 'System::Services',
|
||||
description: 'Defines the backend for geo location lookups to store geo locations for addresses.',
|
||||
options: {
|
||||
form: [
|
||||
{
|
||||
display: '',
|
||||
null: true,
|
||||
name: 'geo_location_backend',
|
||||
tag: 'select',
|
||||
options: {
|
||||
'' => '-',
|
||||
'Service::GeoLocation::Gmaps' => 'Google Maps',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
state: 'Service::GeoLocation::Gmaps',
|
||||
preferences: { prio: 3 },
|
||||
frontend: false
|
||||
)
|
||||
|
||||
|
|
|
@ -111,7 +111,7 @@ returns
|
|||
|
||||
# fetch org logo
|
||||
if admin_user.email
|
||||
Zammad::BigData::Organization.suggest_system_image(admin_user.email)
|
||||
Service::Image.organization_suggest(admin_user.email)
|
||||
end
|
||||
}
|
||||
end
|
||||
|
|
|
@ -1,49 +0,0 @@
|
|||
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||
|
||||
class GeoLocation
|
||||
include ApplicationLib
|
||||
|
||||
=begin
|
||||
|
||||
lookup lat and lng for address
|
||||
|
||||
result = GeoLocation.geocode( 'Marienstrasse 13, 10117 Berlin' )
|
||||
|
||||
returns
|
||||
|
||||
result = [ 4.21312, 1.3123 ]
|
||||
|
||||
=end
|
||||
|
||||
def self.geocode(address)
|
||||
|
||||
# load backend
|
||||
backend = load_adapter_by_setting( 'geo_location_backend' )
|
||||
return if !backend
|
||||
|
||||
# db lookup
|
||||
backend.geocode(address)
|
||||
end
|
||||
|
||||
=begin
|
||||
|
||||
lookup address for lat and lng
|
||||
|
||||
result = GeoLocation.reverse_geocode( 4.21312, 1.3123 )
|
||||
|
||||
returns
|
||||
|
||||
result = 'some address'
|
||||
|
||||
=end
|
||||
|
||||
def self.reverse_geocode(lat, lng)
|
||||
|
||||
# load backend
|
||||
backend = load_adapter_by_setting( 'geo_location_backend' )
|
||||
return if !backend
|
||||
|
||||
# db lookup
|
||||
backend.reverse_geocode(lat, lng)
|
||||
end
|
||||
end
|
|
@ -1,5 +1,6 @@
|
|||
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||
|
||||
module Service
|
||||
class GeoIp
|
||||
include ApplicationLib
|
||||
|
||||
|
@ -7,7 +8,7 @@ class GeoIp
|
|||
|
||||
lookup location based on ip or hostname
|
||||
|
||||
result = GeoIp.location( '172.0.0.1' )
|
||||
result = Service::GeoIp.location( '172.0.0.1' )
|
||||
|
||||
returns
|
||||
|
||||
|
@ -37,3 +38,4 @@ returns
|
|||
backend.location(address)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'cache'
|
||||
|
||||
class GeoIp::ZammadGeoIp
|
||||
class Service::GeoIp::Zammad
|
||||
def self.location(address)
|
||||
|
||||
# check cache
|
51
lib/service/geo_location.rb
Normal file
51
lib/service/geo_location.rb
Normal file
|
@ -0,0 +1,51 @@
|
|||
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||
|
||||
module Service
|
||||
class GeoLocation
|
||||
include ApplicationLib
|
||||
|
||||
=begin
|
||||
|
||||
lookup lat and lng for address
|
||||
|
||||
result = Service::GeoLocation.geocode( 'Marienstrasse 13, 10117 Berlin' )
|
||||
|
||||
returns
|
||||
|
||||
result = [ 4.21312, 1.3123 ]
|
||||
|
||||
=end
|
||||
|
||||
def self.geocode(address)
|
||||
|
||||
# load backend
|
||||
backend = load_adapter_by_setting( 'geo_location_backend' )
|
||||
return if !backend
|
||||
|
||||
# db lookup
|
||||
backend.geocode(address)
|
||||
end
|
||||
|
||||
=begin
|
||||
|
||||
lookup address for lat and lng
|
||||
|
||||
result = GeoLocation.reverse_geocode( 4.21312, 1.3123 )
|
||||
|
||||
returns
|
||||
|
||||
result = 'some address'
|
||||
|
||||
=end
|
||||
|
||||
def self.reverse_geocode(lat, lng)
|
||||
|
||||
# load backend
|
||||
backend = load_adapter_by_setting( 'geo_location_backend' )
|
||||
return if !backend
|
||||
|
||||
# db lookup
|
||||
backend.reverse_geocode(lat, lng)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,6 +1,6 @@
|
|||
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||
|
||||
class GeoLocation::Gmaps
|
||||
class Service::GeoLocation::Gmaps
|
||||
|
||||
def self.geocode(address)
|
||||
url = "http://maps.googleapis.com/maps/api/geocode/json?address=#{CGI.escape address}&sensor=true"
|
79
lib/service/image.rb
Normal file
79
lib/service/image.rb
Normal file
|
@ -0,0 +1,79 @@
|
|||
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||
|
||||
module Service
|
||||
class Image
|
||||
include ApplicationLib
|
||||
|
||||
=begin
|
||||
|
||||
lookup user image based on email address
|
||||
|
||||
file = Service::Image.user( 'skywalker@zammad.org' )
|
||||
|
||||
returns
|
||||
|
||||
{
|
||||
content: content,
|
||||
mime_type: mime_type,
|
||||
}
|
||||
|
||||
=end
|
||||
|
||||
def self.user(address)
|
||||
|
||||
# load backend
|
||||
backend = load_adapter_by_setting( 'image_backend' )
|
||||
return if !backend
|
||||
|
||||
backend.user(address)
|
||||
end
|
||||
|
||||
=begin
|
||||
|
||||
lookup organization image based on domain
|
||||
|
||||
file = Service::Image.organization('edenhofer.de')
|
||||
|
||||
file = Service::Image.organization('user@edenhofer.de') # will just use domain
|
||||
|
||||
returns
|
||||
|
||||
{
|
||||
content: content,
|
||||
mime_type: mime_type,
|
||||
}
|
||||
|
||||
=end
|
||||
|
||||
def self.organization(domain)
|
||||
|
||||
# load backend
|
||||
backend = load_adapter_by_setting( 'image_backend' )
|
||||
return if !backend
|
||||
|
||||
backend.organization(domain)
|
||||
end
|
||||
|
||||
=begin
|
||||
|
||||
find organization image suggestion
|
||||
|
||||
result = Service::Image.organization_suggest('edenhofer.de')
|
||||
|
||||
returns
|
||||
|
||||
true # or false
|
||||
|
||||
=end
|
||||
|
||||
def self.organization_suggest(domain)
|
||||
|
||||
# load backend
|
||||
backend = load_adapter_by_setting( 'image_backend' )
|
||||
return if !backend
|
||||
|
||||
backend.organization_suggest(domain)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
74
lib/service/image/zammad.rb
Normal file
74
lib/service/image/zammad.rb
Normal file
|
@ -0,0 +1,74 @@
|
|||
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||
|
||||
class Service::Image::Zammad
|
||||
|
||||
# rubocop:disable Style/ClassVars
|
||||
@@api_host = 'https://bigdata.zammad.com'
|
||||
@@open_timeout = 4
|
||||
@@read_timeout = 6
|
||||
|
||||
def self.user(email)
|
||||
|
||||
# fetch image
|
||||
response = UserAgent.post(
|
||||
"#{@@api_host}/api/v1/person/image",
|
||||
{
|
||||
email: email,
|
||||
},
|
||||
{
|
||||
open_timeout: @@open_timeout,
|
||||
read_timeout: @@read_timeout,
|
||||
},
|
||||
)
|
||||
if !response.success?
|
||||
Rails.logger.info "Can't fetch image for '#{email}' (maybe no avatar available), http code: #{response.code}"
|
||||
return
|
||||
end
|
||||
Rails.logger.info "Fetched image for '#{email}', http code: #{response.code}"
|
||||
mime_type = 'image/jpeg'
|
||||
{
|
||||
content: response.body,
|
||||
mime_type: mime_type,
|
||||
}
|
||||
end
|
||||
|
||||
def self.organization(domain)
|
||||
|
||||
# strip, just use domain name
|
||||
domain = domain.sub(/^.+?@(.+?)$/, '\1')
|
||||
|
||||
# fetch org logo
|
||||
response = UserAgent.post(
|
||||
"#{@@api_host}/api/v1/organization/image",
|
||||
{
|
||||
domain: domain
|
||||
},
|
||||
{
|
||||
open_timeout: @@open_timeout,
|
||||
read_timeout: @@read_timeout,
|
||||
},
|
||||
)
|
||||
if !response.success?
|
||||
Rails.logger.info "Can't fetch image for '#{domain}' (maybe no avatar available), http code: #{response.code}"
|
||||
return
|
||||
end
|
||||
Rails.logger.info "Fetched image for '#{domain}', http code: #{response.code}"
|
||||
mime_type = 'image/png'
|
||||
|
||||
{
|
||||
content: response.body,
|
||||
mime_type: mime_type,
|
||||
}
|
||||
end
|
||||
|
||||
def self.organization_suggest(domain)
|
||||
image = self.organization(domain)
|
||||
return false if !image
|
||||
|
||||
# store image 1:1
|
||||
product_logo = StaticAssets.store_raw( image[:content], image[:mime_type] )
|
||||
Setting.set('product_logo', product_logo)
|
||||
|
||||
true
|
||||
end
|
||||
end
|
|
@ -1,10 +0,0 @@
|
|||
module Zammad
|
||||
module BigData
|
||||
class Base
|
||||
# rubocop:disable Style/ClassVars
|
||||
@@api_host = 'https://bigdata.zammad.com'
|
||||
@@open_timeout = 4
|
||||
@@read_timeout = 6
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,69 +0,0 @@
|
|||
module Zammad
|
||||
module BigData
|
||||
class Organization < Zammad::BigData::Base
|
||||
|
||||
=begin
|
||||
|
||||
file = Zammad::BigData::Organization.image('edenhofer.de')
|
||||
|
||||
file = Zammad::BigData::Organization.image('user@edenhofer.de') # will just use domain
|
||||
|
||||
returns
|
||||
|
||||
{
|
||||
content: content,
|
||||
mime_type: mime_type,
|
||||
}
|
||||
|
||||
=end
|
||||
def self.image(domain)
|
||||
|
||||
# strip, just use domain name
|
||||
domain = domain.sub(/^.+?@(.+?)$/, '\1')
|
||||
|
||||
# fetch org logo
|
||||
response = UserAgent.post(
|
||||
"#{@@api_host}/api/v1/organization/image",
|
||||
{
|
||||
domain: domain
|
||||
},
|
||||
{
|
||||
open_timeout: @@open_timeout,
|
||||
read_timeout: @@read_timeout,
|
||||
},
|
||||
)
|
||||
if !response.success?
|
||||
Rails.logger.info "Can't fetch image for '#{domain}' (maybe no avatar available), http code: #{response.code}"
|
||||
return
|
||||
end
|
||||
Rails.logger.info "Fetched image for '#{domain}', http code: #{response.code}"
|
||||
mime_type = 'image/png'
|
||||
|
||||
{
|
||||
content: response.body,
|
||||
mime_type: mime_type,
|
||||
}
|
||||
end
|
||||
|
||||
=begin
|
||||
|
||||
result = Zammad::BigData::Organization.suggest_system_image('edenhofer.de')
|
||||
|
||||
returns
|
||||
|
||||
true # or false
|
||||
|
||||
=end
|
||||
def self.suggest_system_image(domain)
|
||||
image = self.image(domain)
|
||||
return false if !image
|
||||
|
||||
# store image 1:1
|
||||
product_logo = StaticAssets.store_raw( image[:content], image[:mime_type] )
|
||||
Setting.set('product_logo', product_logo)
|
||||
|
||||
true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,45 +0,0 @@
|
|||
module Zammad
|
||||
module BigData
|
||||
class User < Zammad::BigData::Base
|
||||
|
||||
=begin
|
||||
|
||||
file = Zammad::BigData::User.image('client@edenhofer.de')
|
||||
|
||||
returns
|
||||
|
||||
{
|
||||
content: content,
|
||||
mime_type: mime_type,
|
||||
}
|
||||
|
||||
=end
|
||||
|
||||
def self.image(email)
|
||||
|
||||
# fetch logo
|
||||
response = UserAgent.post(
|
||||
"#{@@api_host}/api/v1/person/image",
|
||||
{
|
||||
email: email,
|
||||
},
|
||||
{
|
||||
open_timeout: @@open_timeout,
|
||||
read_timeout: @@read_timeout,
|
||||
},
|
||||
)
|
||||
if !response.success?
|
||||
Rails.logger.info "Can't fetch image for '#{email}' (maybe no avatar available), http code: #{response.code}"
|
||||
return
|
||||
end
|
||||
Rails.logger.info "Fetched image for '#{email}', http code: #{response.code}"
|
||||
mime_type = 'image/jpeg'
|
||||
{
|
||||
content: response.body,
|
||||
mime_type: mime_type,
|
||||
}
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
|
@ -6,7 +6,7 @@ class GeoIpTest < ActiveSupport::TestCase
|
|||
# check
|
||||
test 'check some results' do
|
||||
|
||||
result = GeoIp.location( '127.0.0.0.1' )
|
||||
result = Service::GeoIp.location( '127.0.0.0.1' )
|
||||
assert(result)
|
||||
assert_equal(nil, result['country_name'])
|
||||
assert_equal(nil, result['city_name'])
|
||||
|
@ -15,7 +15,7 @@ class GeoIpTest < ActiveSupport::TestCase
|
|||
assert_equal(nil, result['latitude'])
|
||||
assert_equal(nil, result['longitude'])
|
||||
|
||||
result = GeoIp.location( '195.65.29.254' )
|
||||
result = Service::GeoIp.location( '195.65.29.254' )
|
||||
assert(result)
|
||||
assert_equal('Switzerland', result['country_name'])
|
||||
assert_equal('Regensdorf', result['city_name'])
|
||||
|
@ -24,7 +24,7 @@ class GeoIpTest < ActiveSupport::TestCase
|
|||
assert_equal(47.4299, result['latitude'])
|
||||
assert_equal(8.465100000000007, result['longitude'])
|
||||
|
||||
result = GeoIp.location( '134.109.140.74' )
|
||||
result = Service::GeoIp.location( '134.109.140.74' )
|
||||
assert(result)
|
||||
assert_equal('Germany', result['country_name'])
|
||||
assert_equal('Chemnitz', result['city_name'])
|
||||
|
@ -33,7 +33,7 @@ class GeoIpTest < ActiveSupport::TestCase
|
|||
assert_equal(50.83330000000001, result['latitude'])
|
||||
assert_equal(12.916699999999992, result['longitude'])
|
||||
|
||||
result = GeoIp.location( '46.253.55.170' )
|
||||
result = Service::GeoIp.location( '46.253.55.170' )
|
||||
assert(result)
|
||||
assert_equal('Germany', result['country_name'])
|
||||
assert_equal('Halle', result['city_name'])
|
||||
|
@ -42,7 +42,7 @@ class GeoIpTest < ActiveSupport::TestCase
|
|||
assert_equal(51.5, result['latitude'])
|
||||
assert_equal(12.0, result['longitude'])
|
||||
|
||||
result = GeoIp.location( '169.229.216.200' )
|
||||
result = Service::GeoIp.location( '169.229.216.200' )
|
||||
assert(result)
|
||||
assert_equal('United States', result['country_name'])
|
||||
assert_equal('Berkeley', result['city_name'])
|
||||
|
|
|
@ -6,22 +6,22 @@ class GeoLocationTest < ActiveSupport::TestCase
|
|||
# check
|
||||
test 'check simple results' do
|
||||
|
||||
result = GeoLocation.geocode( 'Marienstrasse 13, 10117 Berlin' )
|
||||
result = Service::GeoLocation.geocode( 'Marienstrasse 13, 10117 Berlin' )
|
||||
assert(result)
|
||||
assert_equal(52.52204, result[0])
|
||||
assert_equal(13.38319, result[1])
|
||||
|
||||
result = GeoLocation.geocode( 'Marienstrasse 13 10117 Berlin' )
|
||||
result = Service::GeoLocation.geocode( 'Marienstrasse 13 10117 Berlin' )
|
||||
assert(result)
|
||||
assert_equal(52.52204, result[0])
|
||||
assert_equal(13.38319, result[1])
|
||||
|
||||
result = GeoLocation.geocode( 'Martinsbruggstrasse 35, 9016 St. Gallen' )
|
||||
result = Service::GeoLocation.geocode( 'Martinsbruggstrasse 35, 9016 St. Gallen' )
|
||||
assert(result)
|
||||
assert_equal(47.4366664, result[0])
|
||||
assert_equal(9.409814899999999, result[1])
|
||||
|
||||
result = GeoLocation.geocode( 'Martinsbruggstrasse 35 9016 St. Gallen' )
|
||||
result = Service::GeoLocation.geocode( 'Martinsbruggstrasse 35 9016 St. Gallen' )
|
||||
assert(result)
|
||||
assert_equal(47.4366664, result[0])
|
||||
assert_equal(9.409814899999999, result[1])
|
||||
|
|
Loading…
Reference in a new issue