X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/b56f57ec43dfefa4171dc0cefe26d9e75d4ca2bc..df496b44cd5d52f96bd090815f4f23b4e0f4452f:/test/functional/relation_controller_test.rb diff --git a/test/functional/relation_controller_test.rb b/test/functional/relation_controller_test.rb index b54d9bc98..ffd65f6cc 100644 --- a/test/functional/relation_controller_test.rb +++ b/test/functional/relation_controller_test.rb @@ -210,6 +210,22 @@ class RelationControllerTest < Test::Unit::TestCase delete :delete, :id => current_relations(:visible_relation).id assert_response :bad_request + # try to delete without specifying a changeset + content "" + delete :delete, :id => current_relations(:visible_relation).id + assert_response :conflict + + # try to delete with an invalid (closed) changeset + content update_changeset(current_relations(:visible_relation).to_xml, + changesets(:normal_user_closed_change).id) + delete :delete, :id => current_relations(:visible_relation).id + assert_response :conflict + + # try to delete with an invalid (non-existent) changeset + content update_changeset(current_relations(:visible_relation).to_xml,0) + delete :delete, :id => current_relations(:visible_relation).id + assert_response :conflict + # this won't work because the relation is in-use by another relation content(relations(:used_relation).to_xml) delete :delete, :id => current_relations(:used_relation).id @@ -243,4 +259,24 @@ class RelationControllerTest < Test::Unit::TestCase assert_response :not_found end + ## + # update the changeset_id of a node element + def update_changeset(xml, changeset_id) + xml_attr_rewrite(xml, 'changeset', changeset_id) + end + + ## + # update an attribute in the node element + def xml_attr_rewrite(xml, name, value) + xml.find("//osm/relation").first[name] = value.to_s + return xml + end + + ## + # parse some xml + def xml_parse(xml) + parser = XML::Parser.new + parser.string = xml + parser.parse + end end