X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/6e98e324e58f67b62c6abf343d60ae5e6f22f9eb..d3671694794bafb476b990525db3e2db2dae1bef:/test/functional/node_controller_test.rb diff --git a/test/functional/node_controller_test.rb b/test/functional/node_controller_test.rb index 9d7f48ca4..8d019bf79 100644 --- a/test/functional/node_controller_test.rb +++ b/test/functional/node_controller_test.rb @@ -1,12 +1,11 @@ require File.dirname(__FILE__) + '/../test_helper' -require 'node_controller' class NodeControllerTest < ActionController::TestCase api_fixtures def test_create # cannot read password from fixture as it is stored as MD5 digest - basic_authorization(users(:normal_user).email, "test"); + basic_authorization(users(:normal_user).email, "test") # create a node with random lat/lon lat = rand(100)-50 + rand @@ -30,6 +29,32 @@ class NodeControllerTest < ActionController::TestCase assert_equal true, checknode.visible, "saved node is not visible" end + def test_create_invalid_xml + # Initial setup + basic_authorization(users(:normal_user).email, "test") + # normal user has a changeset open, so we'll use that. + changeset = changesets(:normal_user_first_change) + lat = 3.434 + lon = 3.23 + + # test that the upload is rejected when no lat is supplied + # create a minimal xml file + content("") + put :create + # hope for success + assert_response :bad_request, "node upload did not return bad_request status" + assert_equal 'Cannot parse valid node from xml string . lat missing', @response.body + + # test that the upload is rejected when no lon is supplied + # create a minimal xml file + content("") + put :create + # hope for success + assert_response :bad_request, "node upload did not return bad_request status" + assert_equal 'Cannot parse valid node from xml string . lon missing', @response.body + + end + def test_read # check that a visible node is returned properly get :read, :id => current_nodes(:visible_node).id @@ -251,8 +276,7 @@ class NodeControllerTest < ActionController::TestCase ## # parse some xml def xml_parse(xml) - parser = XML::Parser.new - parser.string = xml + parser = XML::Parser.string(xml) parser.parse end end