X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/d1a29bade4facd38e67c22ee58a02bfdba742ab7..6bb18436a31bc192c20f3df5caf15ac5888471b5:/test/controllers/api/ways_controller_test.rb diff --git a/test/controllers/api/ways_controller_test.rb b/test/controllers/api/ways_controller_test.rb index fa0c47792..0cf30e4ff 100644 --- a/test/controllers/api/ways_controller_test.rb +++ b/test/controllers/api/ways_controller_test.rb @@ -64,31 +64,31 @@ module Api ## # check the "full" mode def test_full - Way.all.each do |way| - get way_full_path(way) - - # full call should say "gone" for non-visible ways... - unless way.visible - assert_response :gone - next - end - - # otherwise it should say success - assert_response :success - - # Check the way is correctly returned - assert_select "osm way[id='#{way.id}'][version='#{way.version}'][visible='#{way.visible}']", 1 - - # check that each node in the way appears once in the output as a - # reference and as the node element. - way.nodes.each do |n| - count = (way.nodes - (way.nodes - [n])).length - assert_select "osm way nd[ref='#{n.id}']", count - assert_select "osm node[id='#{n.id}'][version='#{n.version}'][lat='#{format('%.7f', n.lat)}'][lon='#{format('%.7f', n.lon)}']", 1 - end + way = create(:way_with_nodes, :nodes_count => 3) + + get way_full_path(way) + + assert_response :success + + # Check the way is correctly returned + assert_select "osm way[id='#{way.id}'][version='1'][visible='true']", 1 + + # check that each node in the way appears once in the output as a + # reference and as the node element. + way.nodes.each do |n| + assert_select "osm way nd[ref='#{n.id}']", 1 + assert_select "osm node[id='#{n.id}'][version='1'][lat='#{format('%.7f', :lat => n.lat)}'][lon='#{format('%.7f', :lon => n.lon)}']", 1 end end + def test_full_deleted + way = create(:way, :deleted) + + get way_full_path(way) + + assert_response :gone + end + ## # test fetching multiple ways def test_index @@ -180,8 +180,7 @@ module Api assert_not_nil checkway, "uploaded way not found in data base after upload" # compare values - assert_equal checkway.nds.length, 2, - "saved way does not contain exactly one node" + assert_equal(2, checkway.nds.length, "saved way does not contain exactly one node") assert_equal checkway.nds[0], node1.id, "saved way does not contain the right node on pos 0" assert_equal checkway.nds[1], node2.id, @@ -755,6 +754,8 @@ module Api end end + private + ## # update the changeset_id of a way element def update_changeset(xml, changeset_id)