Commit ebc5cf242b3af6f634100040e4a06f5e7cf2d8db
1 parent
da48ccac
Exists in
staging
and in
42 other branches
GoogleMaps model updated to v3
Showing
3 changed files
with
3 additions
and
64 deletions
 
Show diff stats
app/models/google_maps.rb
| 1 | 1 | class GoogleMaps | 
| 2 | 2 | |
| 3 | - extend ActionView::Helpers::TagHelper | |
| 4 | - | |
| 5 | - class << self | |
| 6 | - | |
| 7 | - include ApplicationHelper | |
| 8 | - | |
| 9 | - def enabled?(domain) | |
| 10 | - domain = Domain.find_by_name(domain) | |
| 11 | - domain ? !domain.google_maps_key.nil? : false | |
| 12 | - end | |
| 13 | - | |
| 14 | - def key(domainname) | |
| 15 | - domain = Domain.find_by_name(domainname) | |
| 16 | - domain && domain.google_maps_key || '' | |
| 17 | - end | |
| 18 | - | |
| 19 | - def initial_zoom | |
| 20 | - NOOSFERO_CONF['googlemaps_initial_zoom'] || 4 | |
| 21 | - end | |
| 22 | - | |
| 23 | - def api_url(domain) | |
| 24 | - "http://maps.google.com/maps?file=api&v=2&key=#{key(domain)}" | |
| 25 | - end | |
| 26 | - | |
| 3 | + def self.initial_zoom | |
| 4 | + NOOSFERO_CONF['googlemaps_initial_zoom'] || 4 | |
| 27 | 5 | end | 
| 6 | + | |
| 28 | 7 | end | ... | ... | 
test/unit/google_maps_test.rb
| ... | ... | @@ -2,25 +2,6 @@ require File.dirname(__FILE__) + '/../test_helper' | 
| 2 | 2 | |
| 3 | 3 | class GoogleMapsTest < ActiveSupport::TestCase | 
| 4 | 4 | |
| 5 | - def setup | |
| 6 | - @domain = fast_create(Domain, :name => 'example-domain', :google_maps_key => 'DOMAIN_KEY') | |
| 7 | - end | |
| 8 | - | |
| 9 | - attr_reader :domain | |
| 10 | - | |
| 11 | - should 'enable when key on domain is defined' do | |
| 12 | - assert GoogleMaps.enabled?(domain.name) | |
| 13 | - end | |
| 14 | - | |
| 15 | - should 'disable if key on domain is not defined' do | |
| 16 | - fast_create(Domain, :name => 'domain-without-key') | |
| 17 | - assert !GoogleMaps.enabled?('domain-without-key') | |
| 18 | - end | |
| 19 | - | |
| 20 | - should 'point correctly to google maps' do | |
| 21 | - assert_equal 'http://maps.google.com/maps?file=api&v=2&key=DOMAIN_KEY', GoogleMaps.api_url(domain.name) | |
| 22 | - end | |
| 23 | - | |
| 24 | 5 | should 'provide initial_zoom setting' do | 
| 25 | 6 | with_constants :NOOSFERO_CONF => {'googlemaps_initial_zoom' => 2} do | 
| 26 | 7 | assert_equal 2, GoogleMaps.initial_zoom | 
| ... | ... | @@ -32,18 +13,4 @@ class GoogleMapsTest < ActiveSupport::TestCase | 
| 32 | 13 | assert_equal 4, GoogleMaps.initial_zoom | 
| 33 | 14 | end | 
| 34 | 15 | |
| 35 | - should 'have different keys to different domains' do | |
| 36 | - other_domain = fast_create(Domain, :name => 'different-domain', :google_maps_key => 'DIFFERENT_DOMAIN_KEY') | |
| 37 | - | |
| 38 | - assert_equal 'http://maps.google.com/maps?file=api&v=2&key=DOMAIN_KEY', GoogleMaps.api_url(domain.name) | |
| 39 | - assert_equal 'http://maps.google.com/maps?file=api&v=2&key=DIFFERENT_DOMAIN_KEY', GoogleMaps.api_url(other_domain.name) | |
| 40 | - end | |
| 41 | - | |
| 42 | - should 'not crash without a domain' do | |
| 43 | - Domain.delete_all | |
| 44 | - assert_nothing_raised do | |
| 45 | - GoogleMaps.key('example.com') | |
| 46 | - end | |
| 47 | - end | |
| 48 | - | |
| 49 | 16 | end | ... | ... | 
test/unit/location_block_test.rb
| ... | ... | @@ -18,13 +18,6 @@ class LocationBlockTest < ActiveSupport::TestCase | 
| 18 | 18 | assert_tag_in_string block.content, :tag => 'i' | 
| 19 | 19 | end | 
| 20 | 20 | |
| 21 | - should 'display localization map' do | |
| 22 | - profile.lat = 0 | |
| 23 | - profile.lng = 0 | |
| 24 | - profile.save! | |
| 25 | - assert_tag_in_string block.content, :tag => 'img' | |
| 26 | - end | |
| 27 | - | |
| 28 | 21 | should 'be editable' do | 
| 29 | 22 | assert LocationBlock.new.editable? | 
| 30 | 23 | end | ... | ... |