google_maps_test.rb
1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
require File.dirname(__FILE__) + '/../test_helper'
class GoogleMapsTest < Test::Unit::TestCase
def setup
@domain = fast_create(Domain, :name => 'example-domain', :google_maps_key => 'DOMAIN_KEY')
end
attr_reader :domain
should 'enable when key on domain is defined' do
assert GoogleMaps.enabled?(domain.name)
end
should 'disable if key on domain is not defined' do
fast_create(Domain, :name => 'domain-without-key')
assert !GoogleMaps.enabled?('domain-without-key')
end
should 'point correctly to google maps' do
assert_equal 'http://maps.google.com/maps?file=api&v=2&key=DOMAIN_KEY', GoogleMaps.api_url(domain.name)
end
should 'provide initial_zoom setting' do
with_constants :NOOSFERO_CONF => {'googlemaps_initial_zoom' => 2} do
assert_equal 2, GoogleMaps.initial_zoom
end
end
should 'use 4 as default initial_zoom' do
GoogleMaps.stubs(:config).returns({})
assert_equal 4, GoogleMaps.initial_zoom
end
should 'have different keys to different domains' do
other_domain = fast_create(Domain, :name => 'different-domain', :google_maps_key => 'DIFFERENT_DOMAIN_KEY')
assert_equal 'http://maps.google.com/maps?file=api&v=2&key=DOMAIN_KEY', GoogleMaps.api_url(domain.name)
assert_equal 'http://maps.google.com/maps?file=api&v=2&key=DIFFERENT_DOMAIN_KEY', GoogleMaps.api_url(other_domain.name)
end
should 'not crash without a domain' do
Domain.delete_all
assert_nothing_raised do
GoogleMaps.key('example.com')
end
end
end