]> git.openstreetmap.org Git - rails.git/blobdiff - test/functional/amf_controller_test.rb
Rework AMF controller's streaming output for rails 3
[rails.git] / test / functional / amf_controller_test.rb
index 3bb1d273e948d4b06e7c2e08bc2753b23831eaf1..1ed8ebf485cc365d8c5864028f18400b8d199789 100644 (file)
@@ -529,6 +529,24 @@ class AmfControllerTest < ActionController::TestCase
     
   end
 
+  def test_startchangeset_invalid_xmlchar_comment
+    invalid = "\035\022"
+    comment = "foo#{invalid}bar"
+      
+    amf_content "startchangeset", "/1", ["test@example.com:test", Hash.new, nil, comment, 1]
+    post :amf_write
+    assert_response :success
+    amf_parse_response
+    result = amf_result("/1")
+
+    assert_equal 3, result.size, result.inspect
+    assert_equal 0, result[0]
+    new_cs_id = result[2]
+
+    cs = Changeset.find(new_cs_id)
+    assert_equal "foobar", cs.tags["comment"]
+  end
+
   # ************************************************************
   # AMF Helper functions
 
@@ -559,13 +577,8 @@ class AmfControllerTest < ActionController::TestCase
   # The result is a hash of message_ref => data.
   # The attribute @amf_result is initialised to this hash.
   def amf_parse_response
-    if @response.body.class.to_s == 'Proc'
-      res = StringIO.new()
-      @response.body.call @response, res
-      req = StringIO.new(res.string)
-    else
-      req = StringIO.new(@response.body)
-    end
+    req = StringIO.new(@response.body)
+
     req.read(2)   # version
 
     # parse through any headers