X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/6e98e324e58f67b62c6abf343d60ae5e6f22f9eb..aeaf2d2d20ddec901c5e509be678d8c7583ce788:/test/functional/node_controller_test.rb diff --git a/test/functional/node_controller_test.rb b/test/functional/node_controller_test.rb index 9d7f48ca4..2289953fe 100644 --- a/test/functional/node_controller_test.rb +++ b/test/functional/node_controller_test.rb @@ -6,7 +6,7 @@ class NodeControllerTest < ActionController::TestCase 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 +30,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