From 654470b896c59e27bec9c3adcf391f2f923110e9 Mon Sep 17 00:00:00 2001 From: Matt Amos Date: Fri, 17 Oct 2008 11:21:40 +0000 Subject: [PATCH 1/1] Altered a functional test on way_tags. --- test/functional/way_controller_test.rb | 29 ++++++++++++++------------ 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/test/functional/way_controller_test.rb b/test/functional/way_controller_test.rb index 8a057c293..0eb77c2e4 100644 --- a/test/functional/way_controller_test.rb +++ b/test/functional/way_controller_test.rb @@ -257,34 +257,37 @@ class WayControllerTest < Test::Unit::TestCase # Try adding a new duplicate tags to a way. # But be a bit subtle - use unicode decoding ambiguities to use different # binary strings which have the same decoding. + # + # NOTE: I'm not sure this test is working correctly, as a lot of the tag + # keys seem to come out as "addr��housenumber". It might be something to + # do with Ruby's unicode handling...? def test_invalid_duplicate_tags # setup auth basic_authorization(users(:normal_user).email, "test") # add the tag into the existing xml way_str = "" + way_str << "" # all of these keys have the same unicode decoding, but are binary # not equal. libxml should make these identical as it decodes the # XML document... - [ "addr:housenumber", - "addr\xc0\xbahousenumber", + [ "addr\xc0\xbahousenumber", "addr\xe0\x80\xbahousenumber", "addr\xf0\x80\x80\xbahousenumber" ].each do |key| - tag_xml = XML::Node.new("tag") - tag_xml['k'] = key - tag_xml['v'] = "1" + # copy the XML doc to add the tags + way_str_copy = way_str.clone # add all new tags to the way - way_str << "" + way_str_copy << "" + way_str_copy << ""; + + # try and upload it + content way_str_copy + put :create + assert_response :bad_request, + "adding new duplicate tags to a way should fail with 'bad request'" end - way_str << ""; - - # try and upload it - content way_str - put :create - assert_response :bad_request, - "adding new duplicate tags to a way should fail with 'bad request'" end ## -- 2.43.2