]> git.openstreetmap.org Git - rails.git/blobdiff - test/functional/changeset_controller_test.rb
Adding an extra test to make sure that the correct response is returned when an inval...
[rails.git] / test / functional / changeset_controller_test.rb
index 848b6d5f58e3a4ca43bad1a044afdbe4f2e994e1..31ade9fce5e3f05000e2ae497f7c2d222be1ddda 100644 (file)
@@ -1,19 +1,8 @@
 require File.dirname(__FILE__) + '/../test_helper'
 require 'changeset_controller'
 
-# Re-raise errors caught by the controller.
-class ChangesetController; def rescue_action(e) raise e end; end
-
-  class ChangesetControllerTest < Test::Unit::TestCase
+class ChangesetControllerTest < ActionController::TestCase
   api_fixtures
-  
-
-
-  def setup
-    @controller = ChangesetController.new
-    @request    = ActionController::TestRequest.new
-    @response   = ActionController::TestResponse.new
-  end
 
   def basic_authorization(user, pass)
     @request.env["HTTP_AUTHORIZATION"] = "Basic %s" % Base64.encode64("#{user}:#{pass}")
@@ -244,7 +233,7 @@ EOF
       "can't upload a complex diff to changeset: #{@response.body}"
 
     # check the returned payload
-    assert_select "osm[version=#{API_VERSION}][generator=\"OpenStreetMap server\"]", 1
+    assert_select "osm[version=#{API_VERSION}][generator=\"#{GENERATOR}\"]", 1
     assert_select "osm>node", 1
     assert_select "osm>way", 1
     assert_select "osm>relation", 1
@@ -380,6 +369,24 @@ EOF
     assert_response :bad_request, 
       "shouldn't be able to upload an element without version: #{@response.body}"
   end
+  
+  ##
+  # try to upload with commands other than create, modify, or delete
+  def test_action_upload_invalid
+    basic_authorization "test@openstreetmap.org", "test"
+    
+    diff = <<EOF
+<osmChange>
+  <ping>
+    <node id='1' lon='1' lat='1' changeset='1' />
+  </ping>
+</osmChange>
+EOF
+  content diff
+  post :upload, :id => 1
+  assert_response :bad_request, "Shouldn't be able to upload a diff with the action ping"
+  assert_equal @response.body, "Unknown action ping, choices are create, modify, delete."
+  end
 
   ##
   # when we make some simple changes we get the same changes back from the