Commit cef5879c08f23672f49aa0b28448ac64710204c3
1 parent
0cb5d2cc
Exists in
master
and in
28 other branches
ActionItem265: adding config. for initial zoom
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1967 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
3 changed files
with
19 additions
and
2 deletions
Show diff stats
app/models/google_maps.rb
@@ -31,6 +31,10 @@ class GoogleMaps | @@ -31,6 +31,10 @@ class GoogleMaps | ||
31 | config['key'] | 31 | config['key'] |
32 | end | 32 | end |
33 | 33 | ||
34 | + def initial_zoom | ||
35 | + config['initial_zoom'] || 4 | ||
36 | + end | ||
37 | + | ||
34 | def api_url | 38 | def api_url |
35 | "http://maps.google.com/maps?file=api&v=2&key=#{key}" | 39 | "http://maps.google.com/maps?file=api&v=2&key=#{key}" |
36 | end | 40 | end |
app/views/search/_google_maps.rhtml
@@ -29,7 +29,7 @@ if (GBrowserIsCompatible()) { | @@ -29,7 +29,7 @@ if (GBrowserIsCompatible()) { | ||
29 | map.addControl(new GMapTypeControl()); | 29 | map.addControl(new GMapTypeControl()); |
30 | 30 | ||
31 | centerPoint = new GLatLng(-15.0, -50.1419); | 31 | centerPoint = new GLatLng(-15.0, -50.1419); |
32 | - map.setCenter(centerPoint, 4); | 32 | + map.setCenter(centerPoint, <%= GoogleMaps.initial_zoom.to_json %>); |
33 | <% | 33 | <% |
34 | missed = false | 34 | missed = false |
35 | @results.each do |name,results| | 35 | @results.each do |name,results| |
test/unit/google_maps_test.rb
@@ -2,11 +2,12 @@ require File.dirname(__FILE__) + '/../test_helper' | @@ -2,11 +2,12 @@ require File.dirname(__FILE__) + '/../test_helper' | ||
2 | 2 | ||
3 | class GoogleMapsTest < Test::Unit::TestCase | 3 | class GoogleMapsTest < Test::Unit::TestCase |
4 | 4 | ||
5 | - CONFIG_FILE = File.join(RAILS_ROOT, 'config', 'web2.0.yml') | 5 | + CONFIG_FILE = '/not/existing.yml' |
6 | 6 | ||
7 | def setup | 7 | def setup |
8 | # force loading of config at every test | 8 | # force loading of config at every test |
9 | GoogleMaps.erase_config | 9 | GoogleMaps.erase_config |
10 | + GoogleMaps.stubs(:config_file).returns(CONFIG_FILE) | ||
10 | end | 11 | end |
11 | 12 | ||
12 | should 'retrieve key from "web2.0" config file' do | 13 | should 'retrieve key from "web2.0" config file' do |
@@ -48,4 +49,16 @@ class GoogleMapsTest < Test::Unit::TestCase | @@ -48,4 +49,16 @@ class GoogleMapsTest < Test::Unit::TestCase | ||
48 | assert_equal 'http://maps.google.com/maps?file=api&v=2&key=MY_FUCKING_KEY', GoogleMaps.api_url | 49 | assert_equal 'http://maps.google.com/maps?file=api&v=2&key=MY_FUCKING_KEY', GoogleMaps.api_url |
49 | end | 50 | end |
50 | 51 | ||
52 | + should 'provide initial_zoom setting' do | ||
53 | + File.expects(:exists?).with(CONFIG_FILE).returns(true) | ||
54 | + YAML.expects(:load_file).with(CONFIG_FILE).returns({'googlemaps' => { 'initial_zoom' => 2}}) | ||
55 | + assert_equal 2, GoogleMaps.initial_zoom | ||
56 | + end | ||
57 | + | ||
58 | + should 'use 4 as default initial_zoom' do | ||
59 | + File.expects(:exists?).with(CONFIG_FILE).returns(true) | ||
60 | + YAML.expects(:load_file).with(CONFIG_FILE).returns({'googlemaps' => { }}) | ||
61 | + assert_equal 4, GoogleMaps.initial_zoom | ||
62 | + end | ||
63 | + | ||
51 | end | 64 | end |