// 700,600 for fixed size, 100%,100% for resizable
}
+ <% if @lat && @lon -%>
+ doSWF(<%= @lat %>,<%= @lon %>,16);
+ <% else -%>
var params = OSM.mapParams();
doSWF(params.lat, params.lon, params.zoom || 17);
+ <% end -%>
$(document).ready(function () {
$("body").on("click", "a.set_position", function () {
// 700,600 for fixed size, 100%,100% for resizable
}
- <% if params[:node] -%>
- <% bbox = Node.find(params[:node]).bbox.to_unscaled -%>
- doSWF(<%= bbox.centre_lat %>,<%= bbox.centre_lon %>,16);
- <% elsif params[:way] -%>
- <% bbox = Way.find(params[:way]).bbox.to_unscaled -%>
- doSWF(<%= bbox.centre_lat %>,<%= bbox.centre_lon %>,16);
- <% elsif params[:gpx] -%>
- <% trace = Trace.find(params[:gpx]) -%>
- doSWF(<%= trace.latitude %>,<%= trace.longitude %>,16);
+ <% if @lat && @lon -%>
+ doSWF(<%= @lat %>,<%= @lon %>,16);
<% else -%>
var params = OSM.mapParams();
doSWF(params.lat, params.lon, params.zoom || 17);
require File.dirname(__FILE__) + '/../test_helper'
class SiteControllerTest < ActionController::TestCase
- fixtures :users
+ api_fixtures
##
# test all routes which lead to this controller
get(:edit, nil, { 'user' => user.id })
assert_response :success
assert_template "index"
- end
+ end
+
+ def test_edit_with_node
+ @request.cookies["_osm_username"] = users(:public_user).display_name
+
+ user = users(:public_user)
+ node = current_nodes(:visible_node)
+
+ get :edit, { :node => node.id }, { 'user' => user.id }
+ assert_equal 1.0, assigns(:lat)
+ assert_equal 1.0, assigns(:lon)
+ end
+
+ def test_edit_with_way
+ @request.cookies["_osm_username"] = users(:public_user).display_name
+
+ user = users(:public_user)
+ way = current_ways(:visible_way)
+
+ get :edit, { :way => way.id }, { 'user' => user.id }
+ assert_equal 3.0, assigns(:lat)
+ assert_equal 3.0, assigns(:lon)
+ end
+
+ def test_edit_with_gpx
+ @request.cookies["_osm_username"] = users(:public_user).display_name
+
+ user = users(:public_user)
+ gpx = gpx_files(:public_trace_file)
+
+ get :edit, { :gpx => gpx.id }, { 'user' => user.id }
+ assert_equal 1.0, assigns(:lat)
+ assert_equal 1.0, assigns(:lon)
+ end
end