X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/2347761266d8848dcdc42f9e5d9ef380fa04b89a..a2498928e470b358f69902d9fdc72a1a80aa5bf8:/test/functional/node_controller_test.rb diff --git a/test/functional/node_controller_test.rb b/test/functional/node_controller_test.rb index 59b28e114..a8ef700a3 100644 --- a/test/functional/node_controller_test.rb +++ b/test/functional/node_controller_test.rb @@ -21,10 +21,14 @@ class NodeControllerTest < Test::Unit::TestCase # create a node with random lat/lon lat = rand(100)-50 + rand lon = rand(100)-50 + rand - content("") + # normal user has a changeset open, so we'll use that. + changeset = changesets(:normal_user_first_change) + # create a minimal xml file + content("") put :create # hope for success assert_response :success, "node upload did not return success status" + # read id of created node and search for it nodeid = @response.body checknode = Node.find(nodeid) @@ -32,7 +36,7 @@ class NodeControllerTest < Test::Unit::TestCase # compare values assert_in_delta lat * 10000000, checknode.latitude, 1, "saved node does not match requested latitude" assert_in_delta lon * 10000000, checknode.longitude, 1, "saved node does not match requested longitude" - assert_equal users(:normal_user).id, checknode.user_id, "saved node does not belong to user that created it" + assert_equal changesets(:normal_user_first_change).id, checknode.changeset_id, "saved node does not belong to changeset that it was created in" assert_equal true, checknode.visible, "saved node is not visible" end @@ -61,11 +65,13 @@ class NodeControllerTest < Test::Unit::TestCase # now set auth basic_authorization(users(:normal_user).email, "test"); - # this should work + # delete now takes a payload + content(nodes(:visible_node).to_xml) delete :delete, :id => current_nodes(:visible_node).id assert_response :success # this won't work since the node is already deleted + content(nodes(:invisible_node).to_xml) delete :delete, :id => current_nodes(:invisible_node).id assert_response :gone @@ -74,6 +80,7 @@ class NodeControllerTest < Test::Unit::TestCase assert_response :not_found # this won't work since the node is in use + content(nodes(:used_node_1).to_xml) delete :delete, :id => current_nodes(:used_node_1).id assert_response :precondition_failed end @@ -84,6 +91,6 @@ class NodeControllerTest < Test::Unit::TestCase end def content(c) - @request.env["RAW_POST_DATA"] = c + @request.env["RAW_POST_DATA"] = c.to_s end end