Commit cef5879c08f23672f49aa0b28448ac64710204c3
1 parent
0cb5d2cc
Exists in
master
and in
23 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
app/views/search/_google_maps.rhtml
| ... | ... | @@ -29,7 +29,7 @@ if (GBrowserIsCompatible()) { |
| 29 | 29 | map.addControl(new GMapTypeControl()); |
| 30 | 30 | |
| 31 | 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 | 34 | missed = false |
| 35 | 35 | @results.each do |name,results| | ... | ... |
test/unit/google_maps_test.rb
| ... | ... | @@ -2,11 +2,12 @@ require File.dirname(__FILE__) + '/../test_helper' |
| 2 | 2 | |
| 3 | 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 | 7 | def setup |
| 8 | 8 | # force loading of config at every test |
| 9 | 9 | GoogleMaps.erase_config |
| 10 | + GoogleMaps.stubs(:config_file).returns(CONFIG_FILE) | |
| 10 | 11 | end |
| 11 | 12 | |
| 12 | 13 | should 'retrieve key from "web2.0" config file' do |
| ... | ... | @@ -48,4 +49,16 @@ class GoogleMapsTest < Test::Unit::TestCase |
| 48 | 49 | assert_equal 'http://maps.google.com/maps?file=api&v=2&key=MY_FUCKING_KEY', GoogleMaps.api_url |
| 49 | 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 | 64 | end | ... | ... |