From ebc5cf242b3af6f634100040e4a06f5e7cf2d8db Mon Sep 17 00:00:00 2001 From: Rafael Martins Date: Fri, 24 Feb 2012 17:07:44 -0200 Subject: [PATCH] GoogleMaps model updated to v3 --- app/models/google_maps.rb | 27 +++------------------------ test/unit/google_maps_test.rb | 33 --------------------------------- test/unit/location_block_test.rb | 7 ------- 3 files changed, 3 insertions(+), 64 deletions(-) diff --git a/app/models/google_maps.rb b/app/models/google_maps.rb index 5fce0bb..d1268c7 100644 --- a/app/models/google_maps.rb +++ b/app/models/google_maps.rb @@ -1,28 +1,7 @@ class GoogleMaps - extend ActionView::Helpers::TagHelper - - class << self - - include ApplicationHelper - - def enabled?(domain) - domain = Domain.find_by_name(domain) - domain ? !domain.google_maps_key.nil? : false - end - - def key(domainname) - domain = Domain.find_by_name(domainname) - domain && domain.google_maps_key || '' - end - - def initial_zoom - NOOSFERO_CONF['googlemaps_initial_zoom'] || 4 - end - - def api_url(domain) - "http://maps.google.com/maps?file=api&v=2&key=#{key(domain)}" - end - + def self.initial_zoom + NOOSFERO_CONF['googlemaps_initial_zoom'] || 4 end + end diff --git a/test/unit/google_maps_test.rb b/test/unit/google_maps_test.rb index 987ab75..8604930 100644 --- a/test/unit/google_maps_test.rb +++ b/test/unit/google_maps_test.rb @@ -2,25 +2,6 @@ require File.dirname(__FILE__) + '/../test_helper' class GoogleMapsTest < ActiveSupport::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 @@ -32,18 +13,4 @@ class GoogleMapsTest < ActiveSupport::TestCase 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 diff --git a/test/unit/location_block_test.rb b/test/unit/location_block_test.rb index f06f65a..e556671 100644 --- a/test/unit/location_block_test.rb +++ b/test/unit/location_block_test.rb @@ -18,13 +18,6 @@ class LocationBlockTest < ActiveSupport::TestCase assert_tag_in_string block.content, :tag => 'i' end - should 'display localization map' do - profile.lat = 0 - profile.lng = 0 - profile.save! - assert_tag_in_string block.content, :tag => 'img' - end - should 'be editable' do assert LocationBlock.new.editable? end -- libgit2 0.21.2