4 class WaysControllerTest < ActionController::TestCase
6 # test all routes which lead to this controller
9 { :path => "/api/0.6/way/create", :method => :put },
10 { :controller => "api/ways", :action => "create" }
13 { :path => "/api/0.6/way/1/full", :method => :get },
14 { :controller => "api/ways", :action => "full", :id => "1" }
17 { :path => "/api/0.6/way/1", :method => :get },
18 { :controller => "api/ways", :action => "show", :id => "1" }
21 { :path => "/api/0.6/way/1", :method => :put },
22 { :controller => "api/ways", :action => "update", :id => "1" }
25 { :path => "/api/0.6/way/1", :method => :delete },
26 { :controller => "api/ways", :action => "delete", :id => "1" }
29 { :path => "/api/0.6/ways", :method => :get },
30 { :controller => "api/ways", :action => "index" }
34 # -------------------------------------
36 # -------------------------------------
39 # check that a visible way is returned properly
40 get :show, :params => { :id => create(:way).id }
41 assert_response :success
43 # check that an invisible way is not returned
44 get :show, :params => { :id => create(:way, :deleted).id }
47 # check chat a non-existent way is not returned
48 get :show, :params => { :id => 0 }
49 assert_response :not_found
53 # check the "full" mode
56 get :full, :params => { :id => way.id }
58 # full call should say "gone" for non-visible ways...
64 # otherwise it should say success
65 assert_response :success
67 # Check the way is correctly returned
68 assert_select "osm way[id='#{way.id}'][version='#{way.version}'][visible='#{way.visible}']", 1
70 # check that each node in the way appears once in the output as a
71 # reference and as the node element.
73 count = (way.nodes - (way.nodes - [n])).length
74 assert_select "osm way nd[ref='#{n.id}']", count
75 assert_select "osm node[id='#{n.id}'][version='#{n.version}'][lat='#{format('%.7f', n.lat)}'][lon='#{format('%.7f', n.lon)}']", 1
81 # test fetching multiple ways
84 way2 = create(:way, :deleted)
88 # check error when no parameter provided
90 assert_response :bad_request
92 # check error when no parameter value provided
93 get :index, :params => { :ways => "" }
94 assert_response :bad_request
97 get :index, :params => { :ways => "#{way1.id},#{way2.id},#{way3.id},#{way4.id}" }
98 assert_response :success
99 assert_select "osm" do
100 assert_select "way", :count => 4
101 assert_select "way[id='#{way1.id}'][visible='true']", :count => 1
102 assert_select "way[id='#{way2.id}'][visible='false']", :count => 1
103 assert_select "way[id='#{way3.id}'][visible='true']", :count => 1
104 assert_select "way[id='#{way4.id}'][visible='true']", :count => 1
107 # check error when a non-existent way is included
108 get :index, :params => { :ways => "#{way1.id},#{way2.id},#{way3.id},#{way4.id},0" }
109 assert_response :not_found
112 # -------------------------------------
113 # Test simple way creation.
114 # -------------------------------------
117 node1 = create(:node)
118 node2 = create(:node)
119 private_user = create(:user, :data_public => false)
120 private_changeset = create(:changeset, :user => private_user)
122 changeset = create(:changeset, :user => user)
124 ## First check that it fails when creating a way using a non-public user
125 basic_authorization private_user.email, "test"
127 # use the first user's open changeset
128 changeset_id = private_changeset.id
130 # create a way with pre-existing nodes
131 xml = "<osm><way changeset='#{changeset_id}'>" \
132 "<nd ref='#{node1.id}'/><nd ref='#{node2.id}'/>" \
133 "<tag k='test' v='yes' /></way></osm>"
134 put :create, :body => xml
136 assert_response :forbidden,
137 "way upload did not return forbidden status"
139 ## Now use a public user
140 basic_authorization user.email, "test"
142 # use the first user's open changeset
143 changeset_id = changeset.id
145 # create a way with pre-existing nodes
146 xml = "<osm><way changeset='#{changeset_id}'>" \
147 "<nd ref='#{node1.id}'/><nd ref='#{node2.id}'/>" \
148 "<tag k='test' v='yes' /></way></osm>"
149 put :create, :body => xml
151 assert_response :success,
152 "way upload did not return success status"
153 # read id of created way and search for it
154 wayid = @response.body
155 checkway = Way.find(wayid)
156 assert_not_nil checkway,
157 "uploaded way not found in data base after upload"
159 assert_equal checkway.nds.length, 2,
160 "saved way does not contain exactly one node"
161 assert_equal checkway.nds[0], node1.id,
162 "saved way does not contain the right node on pos 0"
163 assert_equal checkway.nds[1], node2.id,
164 "saved way does not contain the right node on pos 1"
165 assert_equal checkway.changeset_id, changeset_id,
166 "saved way does not belong to the correct changeset"
167 assert_equal user.id, checkway.changeset.user_id,
168 "saved way does not belong to user that created it"
169 assert_equal true, checkway.visible,
170 "saved way is not visible"
173 # -------------------------------------
174 # Test creating some invalid ways.
175 # -------------------------------------
177 def test_create_invalid
179 private_user = create(:user, :data_public => false)
180 private_open_changeset = create(:changeset, :user => private_user)
181 private_closed_changeset = create(:changeset, :closed, :user => private_user)
183 open_changeset = create(:changeset, :user => user)
184 closed_changeset = create(:changeset, :closed, :user => user)
186 ## First test with a private user to make sure that they are not authorized
187 basic_authorization private_user.email, "test"
189 # use the first user's open changeset
190 # create a way with non-existing node
191 xml = "<osm><way changeset='#{private_open_changeset.id}'>" \
192 "<nd ref='0'/><tag k='test' v='yes' /></way></osm>"
193 put :create, :body => xml
195 assert_response :forbidden,
196 "way upload with invalid node using a private user did not return 'forbidden'"
198 # create a way with no nodes
199 xml = "<osm><way changeset='#{private_open_changeset.id}'>" \
200 "<tag k='test' v='yes' /></way></osm>"
201 put :create, :body => xml
203 assert_response :forbidden,
204 "way upload with no node using a private userdid not return 'forbidden'"
206 # create a way inside a closed changeset
207 xml = "<osm><way changeset='#{private_closed_changeset.id}'>" \
208 "<nd ref='#{node.id}'/></way></osm>"
209 put :create, :body => xml
211 assert_response :forbidden,
212 "way upload to closed changeset with a private user did not return 'forbidden'"
214 ## Now test with a public user
215 basic_authorization user.email, "test"
217 # use the first user's open changeset
218 # create a way with non-existing node
219 xml = "<osm><way changeset='#{open_changeset.id}'>" \
220 "<nd ref='0'/><tag k='test' v='yes' /></way></osm>"
221 put :create, :body => xml
223 assert_response :precondition_failed,
224 "way upload with invalid node did not return 'precondition failed'"
225 assert_equal "Precondition failed: Way requires the nodes with id in (0), which either do not exist, or are not visible.", @response.body
227 # create a way with no nodes
228 xml = "<osm><way changeset='#{open_changeset.id}'>" \
229 "<tag k='test' v='yes' /></way></osm>"
230 put :create, :body => xml
232 assert_response :precondition_failed,
233 "way upload with no node did not return 'precondition failed'"
234 assert_equal "Precondition failed: Cannot create way: data is invalid.", @response.body
236 # create a way inside a closed changeset
237 xml = "<osm><way changeset='#{closed_changeset.id}'>" \
238 "<nd ref='#{node.id}'/></way></osm>"
239 put :create, :body => xml
241 assert_response :conflict,
242 "way upload to closed changeset did not return 'conflict'"
244 # create a way with a tag which is too long
245 xml = "<osm><way changeset='#{open_changeset.id}'>" \
246 "<nd ref='#{node.id}'/>" \
247 "<tag k='foo' v='#{'x' * 256}'/>" \
249 put :create, :body => xml
251 assert_response :bad_request,
252 "way upload to with too long tag did not return 'bad_request'"
255 # -------------------------------------
256 # Test deleting ways.
257 # -------------------------------------
260 private_user = create(:user, :data_public => false)
261 private_open_changeset = create(:changeset, :user => private_user)
262 private_closed_changeset = create(:changeset, :closed, :user => private_user)
263 private_way = create(:way, :changeset => private_open_changeset)
264 private_deleted_way = create(:way, :deleted, :changeset => private_open_changeset)
265 private_used_way = create(:way, :changeset => private_open_changeset)
266 create(:relation_member, :member => private_used_way)
268 open_changeset = create(:changeset, :user => user)
269 closed_changeset = create(:changeset, :closed, :user => user)
270 way = create(:way, :changeset => open_changeset)
271 deleted_way = create(:way, :deleted, :changeset => open_changeset)
272 used_way = create(:way, :changeset => open_changeset)
273 relation_member = create(:relation_member, :member => used_way)
274 relation = relation_member.relation
276 # first try to delete way without auth
277 delete :delete, :params => { :id => way.id }
278 assert_response :unauthorized
280 # now set auth using the private user
281 basic_authorization private_user.email, "test"
283 # this shouldn't work as with the 0.6 api we need pay load to delete
284 delete :delete, :params => { :id => private_way.id }
285 assert_response :forbidden
287 # Now try without having a changeset
288 xml = "<osm><way id='#{private_way.id}'/></osm>"
289 delete :delete, :params => { :id => private_way.id }, :body => xml.to_s
290 assert_response :forbidden
292 # try to delete with an invalid (closed) changeset
293 xml = update_changeset(private_way.to_xml, private_closed_changeset.id)
294 delete :delete, :params => { :id => private_way.id }, :body => xml.to_s
295 assert_response :forbidden
297 # try to delete with an invalid (non-existent) changeset
298 xml = update_changeset(private_way.to_xml, 0)
299 delete :delete, :params => { :id => private_way.id }, :body => xml.to_s
300 assert_response :forbidden
302 # Now try with a valid changeset
303 xml = private_way.to_xml
304 delete :delete, :params => { :id => private_way.id }, :body => xml.to_s
305 assert_response :forbidden
307 # check the returned value - should be the new version number
308 # valid delete should return the new version number, which should
309 # be greater than the old version number
310 # assert @response.body.to_i > current_ways(:visible_way).version,
311 # "delete request should return a new version number for way"
313 # this won't work since the way is already deleted
314 xml = private_deleted_way.to_xml
315 delete :delete, :params => { :id => private_deleted_way.id }, :body => xml.to_s
316 assert_response :forbidden
318 # this shouldn't work as the way is used in a relation
319 xml = private_used_way.to_xml
320 delete :delete, :params => { :id => private_used_way.id }, :body => xml.to_s
321 assert_response :forbidden,
322 "shouldn't be able to delete a way used in a relation (#{@response.body}), when done by a private user"
324 # this won't work since the way never existed
325 delete :delete, :params => { :id => 0 }
326 assert_response :forbidden
328 ### Now check with a public user
330 basic_authorization user.email, "test"
332 # this shouldn't work as with the 0.6 api we need pay load to delete
333 delete :delete, :params => { :id => way.id }
334 assert_response :bad_request
336 # Now try without having a changeset
337 xml = "<osm><way id='#{way.id}'/></osm>"
338 delete :delete, :params => { :id => way.id }, :body => xml.to_s
339 assert_response :bad_request
341 # try to delete with an invalid (closed) changeset
342 xml = update_changeset(way.to_xml, closed_changeset.id)
343 delete :delete, :params => { :id => way.id }, :body => xml.to_s
344 assert_response :conflict
346 # try to delete with an invalid (non-existent) changeset
347 xml = update_changeset(way.to_xml, 0)
348 delete :delete, :params => { :id => way.id }, :body => xml.to_s
349 assert_response :conflict
351 # Now try with a valid changeset
353 delete :delete, :params => { :id => way.id }, :body => xml.to_s
354 assert_response :success
356 # check the returned value - should be the new version number
357 # valid delete should return the new version number, which should
358 # be greater than the old version number
359 assert @response.body.to_i > way.version,
360 "delete request should return a new version number for way"
362 # this won't work since the way is already deleted
363 xml = deleted_way.to_xml
364 delete :delete, :params => { :id => deleted_way.id }, :body => xml.to_s
365 assert_response :gone
367 # this shouldn't work as the way is used in a relation
368 xml = used_way.to_xml
369 delete :delete, :params => { :id => used_way.id }, :body => xml.to_s
370 assert_response :precondition_failed,
371 "shouldn't be able to delete a way used in a relation (#{@response.body})"
372 assert_equal "Precondition failed: Way #{used_way.id} is still used by relations #{relation.id}.", @response.body
374 # this won't work since the way never existed
375 delete :delete, :params => { :id => 0 }
376 assert_response :not_found
380 # tests whether the API works and prevents incorrect use while trying
383 private_user = create(:user, :data_public => false)
384 private_way = create(:way, :changeset => create(:changeset, :user => private_user))
386 way = create(:way, :changeset => create(:changeset, :user => user))
388 create(:way_node, :way => private_way, :node => node)
389 create(:way_node, :way => way, :node => node)
391 ## First test with no user credentials
392 # try and update a way without authorisation
394 put :update, :params => { :id => way.id }, :body => xml.to_s
395 assert_response :unauthorized
397 ## Second test with the private user
400 basic_authorization private_user.email, "test"
402 ## trying to break changesets
404 # try and update in someone else's changeset
405 xml = update_changeset(private_way.to_xml,
406 create(:changeset).id)
407 put :update, :params => { :id => private_way.id }, :body => xml.to_s
408 assert_require_public_data "update with other user's changeset should be forbidden when date isn't public"
410 # try and update in a closed changeset
411 xml = update_changeset(private_way.to_xml,
412 create(:changeset, :closed, :user => private_user).id)
413 put :update, :params => { :id => private_way.id }, :body => xml.to_s
414 assert_require_public_data "update with closed changeset should be forbidden, when data isn't public"
416 # try and update in a non-existant changeset
417 xml = update_changeset(private_way.to_xml, 0)
418 put :update, :params => { :id => private_way.id }, :body => xml.to_s
419 assert_require_public_data("update with changeset=0 should be forbidden, when data isn't public")
421 ## try and submit invalid updates
422 xml = xml_replace_node(private_way.to_xml, node.id, 9999)
423 put :update, :params => { :id => private_way.id }, :body => xml.to_s
424 assert_require_public_data "way with non-existent node should be forbidden, when data isn't public"
426 xml = xml_replace_node(private_way.to_xml, node.id, create(:node, :deleted).id)
427 put :update, :params => { :id => private_way.id }, :body => xml.to_s
428 assert_require_public_data "way with deleted node should be forbidden, when data isn't public"
430 ## finally, produce a good request which will still not work
431 xml = private_way.to_xml
432 put :update, :params => { :id => private_way.id }, :body => xml.to_s
433 assert_require_public_data "should have failed with a forbidden when data isn't public"
435 ## Finally test with the public user
438 basic_authorization user.email, "test"
440 ## trying to break changesets
442 # try and update in someone else's changeset
443 xml = update_changeset(way.to_xml,
444 create(:changeset).id)
445 put :update, :params => { :id => way.id }, :body => xml.to_s
446 assert_response :conflict, "update with other user's changeset should be rejected"
448 # try and update in a closed changeset
449 xml = update_changeset(way.to_xml,
450 create(:changeset, :closed, :user => user).id)
451 put :update, :params => { :id => way.id }, :body => xml.to_s
452 assert_response :conflict, "update with closed changeset should be rejected"
454 # try and update in a non-existant changeset
455 xml = update_changeset(way.to_xml, 0)
456 put :update, :params => { :id => way.id }, :body => xml.to_s
457 assert_response :conflict, "update with changeset=0 should be rejected"
459 ## try and submit invalid updates
460 xml = xml_replace_node(way.to_xml, node.id, 9999)
461 put :update, :params => { :id => way.id }, :body => xml.to_s
462 assert_response :precondition_failed, "way with non-existent node should be rejected"
464 xml = xml_replace_node(way.to_xml, node.id, create(:node, :deleted).id)
465 put :update, :params => { :id => way.id }, :body => xml.to_s
466 assert_response :precondition_failed, "way with deleted node should be rejected"
468 ## next, attack the versioning
469 current_way_version = way.version
471 # try and submit a version behind
472 xml = xml_attr_rewrite(way.to_xml,
473 "version", current_way_version - 1)
474 put :update, :params => { :id => way.id }, :body => xml.to_s
475 assert_response :conflict, "should have failed on old version number"
477 # try and submit a version ahead
478 xml = xml_attr_rewrite(way.to_xml,
479 "version", current_way_version + 1)
480 put :update, :params => { :id => way.id }, :body => xml.to_s
481 assert_response :conflict, "should have failed on skipped version number"
483 # try and submit total crap in the version field
484 xml = xml_attr_rewrite(way.to_xml,
485 "version", "p1r4t3s!")
486 put :update, :params => { :id => way.id }, :body => xml.to_s
487 assert_response :conflict,
488 "should not be able to put 'p1r4at3s!' in the version field"
490 ## try an update with the wrong ID
491 xml = create(:way).to_xml
492 put :update, :params => { :id => way.id }, :body => xml.to_s
493 assert_response :bad_request,
494 "should not be able to update a way with a different ID from the XML"
496 ## try an update with a minimal valid XML doc which isn't a well-formed OSM doc.
498 put :update, :params => { :id => way.id }, :body => xml.to_s
499 assert_response :bad_request,
500 "should not be able to update a way with non-OSM XML doc."
502 ## finally, produce a good request which should work
504 put :update, :params => { :id => way.id }, :body => xml.to_s
505 assert_response :success, "a valid update request failed"
508 # ------------------------------------------------------------
510 # ------------------------------------------------------------
513 # Try adding a new tag to a way
515 private_user = create(:user, :data_public => false)
516 private_way = create(:way_with_nodes, :nodes_count => 2, :changeset => create(:changeset, :user => private_user))
518 way = create(:way_with_nodes, :nodes_count => 2, :changeset => create(:changeset, :user => user))
520 ## Try with the non-public user
522 basic_authorization private_user.email, "test"
524 # add an identical tag to the way
525 tag_xml = XML::Node.new("tag")
529 # add the tag into the existing xml
530 way_xml = private_way.to_xml
531 way_xml.find("//osm/way").first << tag_xml
534 put :update, :params => { :id => private_way.id }, :body => way_xml.to_s
535 assert_response :forbidden,
536 "adding a duplicate tag to a way for a non-public should fail with 'forbidden'"
538 ## Now try with the public user
540 basic_authorization user.email, "test"
542 # add an identical tag to the way
543 tag_xml = XML::Node.new("tag")
547 # add the tag into the existing xml
549 way_xml.find("//osm/way").first << tag_xml
552 put :update, :params => { :id => way.id }, :body => way_xml.to_s
553 assert_response :success,
554 "adding a new tag to a way should succeed"
555 assert_equal way.version + 1, @response.body.to_i
559 # Try adding a duplicate of an existing tag to a way
560 def test_add_duplicate_tags
561 private_user = create(:user, :data_public => false)
562 private_way = create(:way, :changeset => create(:changeset, :user => private_user))
563 private_existing_tag = create(:way_tag, :way => private_way)
565 way = create(:way, :changeset => create(:changeset, :user => user))
566 existing_tag = create(:way_tag, :way => way)
568 ## Try with the non-public user
570 basic_authorization private_user.email, "test"
572 # add an identical tag to the way
573 tag_xml = XML::Node.new("tag")
574 tag_xml["k"] = private_existing_tag.k
575 tag_xml["v"] = private_existing_tag.v
577 # add the tag into the existing xml
578 way_xml = private_way.to_xml
579 way_xml.find("//osm/way").first << tag_xml
582 put :update, :params => { :id => private_way.id }, :body => way_xml.to_s
583 assert_response :forbidden,
584 "adding a duplicate tag to a way for a non-public should fail with 'forbidden'"
586 ## Now try with the public user
588 basic_authorization user.email, "test"
590 # add an identical tag to the way
591 tag_xml = XML::Node.new("tag")
592 tag_xml["k"] = existing_tag.k
593 tag_xml["v"] = existing_tag.v
595 # add the tag into the existing xml
597 way_xml.find("//osm/way").first << tag_xml
600 put :update, :params => { :id => way.id }, :body => way_xml.to_s
601 assert_response :bad_request,
602 "adding a duplicate tag to a way should fail with 'bad request'"
603 assert_equal "Element way/#{way.id} has duplicate tags with key #{existing_tag.k}", @response.body
607 # Try adding a new duplicate tags to a way
608 def test_new_duplicate_tags
609 private_user = create(:user, :data_public => false)
610 private_way = create(:way, :changeset => create(:changeset, :user => private_user))
612 way = create(:way, :changeset => create(:changeset, :user => user))
614 ## First test with the non-public user so should be rejected
616 basic_authorization private_user.email, "test"
618 # create duplicate tag
619 tag_xml = XML::Node.new("tag")
620 tag_xml["k"] = "i_am_a_duplicate"
621 tag_xml["v"] = "foobar"
623 # add the tag into the existing xml
624 way_xml = private_way.to_xml
626 # add two copies of the tag
627 way_xml.find("//osm/way").first << tag_xml.copy(true) << tag_xml
630 put :update, :params => { :id => private_way.id }, :body => way_xml.to_s
631 assert_response :forbidden,
632 "adding new duplicate tags to a way using a non-public user should fail with 'forbidden'"
634 ## Now test with the public user
636 basic_authorization user.email, "test"
638 # create duplicate tag
639 tag_xml = XML::Node.new("tag")
640 tag_xml["k"] = "i_am_a_duplicate"
641 tag_xml["v"] = "foobar"
643 # add the tag into the existing xml
646 # add two copies of the tag
647 way_xml.find("//osm/way").first << tag_xml.copy(true) << tag_xml
650 put :update, :params => { :id => way.id }, :body => way_xml.to_s
651 assert_response :bad_request,
652 "adding new duplicate tags to a way should fail with 'bad request'"
653 assert_equal "Element way/#{way.id} has duplicate tags with key i_am_a_duplicate", @response.body
657 # Try adding a new duplicate tags to a way.
658 # But be a bit subtle - use unicode decoding ambiguities to use different
659 # binary strings which have the same decoding.
660 def test_invalid_duplicate_tags
661 private_user = create(:user, :data_public => false)
662 private_changeset = create(:changeset, :user => private_user)
664 changeset = create(:changeset, :user => user)
666 ## First make sure that you can't with a non-public user
668 basic_authorization private_user.email, "test"
670 # add the tag into the existing xml
671 way_str = "<osm><way changeset='#{private_changeset.id}'>"
672 way_str << "<tag k='addr:housenumber' v='1'/>"
673 way_str << "<tag k='addr:housenumber' v='2'/>"
674 way_str << "</way></osm>"
677 put :create, :body => way_str
678 assert_response :forbidden,
679 "adding new duplicate tags to a way with a non-public user should fail with 'forbidden'"
681 ## Now do it with a public user
683 basic_authorization user.email, "test"
685 # add the tag into the existing xml
686 way_str = "<osm><way changeset='#{changeset.id}'>"
687 way_str << "<tag k='addr:housenumber' v='1'/>"
688 way_str << "<tag k='addr:housenumber' v='2'/>"
689 way_str << "</way></osm>"
692 put :create, :body => way_str
693 assert_response :bad_request,
694 "adding new duplicate tags to a way should fail with 'bad request'"
695 assert_equal "Element way/ has duplicate tags with key addr:housenumber", @response.body
699 # test that a call to ways_for_node returns all ways that contain the node
700 # and none that don't.
701 def test_ways_for_node
705 create(:way_node, :way => way1, :node => node)
706 create(:way_node, :way => way2, :node => node)
707 # create an unrelated way
708 create(:way_with_nodes, :nodes_count => 2)
709 # create a way which used to use the node
710 way3_v1 = create(:old_way, :version => 1)
711 _way3_v2 = create(:old_way, :current_way => way3_v1.current_way, :version => 2)
712 create(:old_way_node, :old_way => way3_v1, :node => node)
714 get :ways_for_node, :params => { :id => node.id }
715 assert_response :success
716 ways_xml = XML::Parser.string(@response.body).parse
717 assert_not_nil ways_xml, "failed to parse ways_for_node response"
719 # check that the set of IDs match expectations
720 expected_way_ids = [way1.id,
722 found_way_ids = ways_xml.find("//osm/way").collect { |w| w["id"].to_i }
723 assert_equal expected_way_ids.sort, found_way_ids.sort,
724 "expected ways for node #{node.id} did not match found"
726 # check the full ways to ensure we're not missing anything
727 expected_way_ids.each do |id|
728 way_xml = ways_xml.find("//osm/way[@id='#{id}']").first
729 assert_ways_are_equal(Way.find(id),
730 Way.from_xml_node(way_xml))
735 # update the changeset_id of a way element
736 def update_changeset(xml, changeset_id)
737 xml_attr_rewrite(xml, "changeset", changeset_id)
741 # update an attribute in the way element
742 def xml_attr_rewrite(xml, name, value)
743 xml.find("//osm/way").first[name] = value.to_s
748 # replace a node in a way element
749 def xml_replace_node(xml, old_node, new_node)
750 xml.find("//osm/way/nd[@ref='#{old_node}']").first["ref"] = new_node.to_s