X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/dc2a95903722644f6109244cec9a2d1e195fef0e..32b280eb8dfd11d03646cb89c339d2b938f06a6e:/test/functional/changeset_controller_test.rb
diff --git a/test/functional/changeset_controller_test.rb b/test/functional/changeset_controller_test.rb
index 946d139d8..5e26c2071 100644
--- a/test/functional/changeset_controller_test.rb
+++ b/test/functional/changeset_controller_test.rb
@@ -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}")
@@ -381,4 +370,104 @@ EOF
"shouldn't be able to upload an element without version: #{@response.body}"
end
+ ##
+ # when we make some simple changes we get the same changes back from the
+ # diff download.
+ def test_diff_download_simple
+ basic_authorization(users(:normal_user).email, "test")
+
+ # create a temporary changeset
+ content "" +
+ "" +
+ ""
+ put :create
+ assert_response :success
+ changeset_id = @response.body.to_i
+
+ # add a diff to it
+ diff = <
+
+
+
+
+
+
+
+
+
+
+
+EOF
+
+ # upload it
+ content diff
+ post :upload, :id => changeset_id
+ assert_response :success,
+ "can't upload multiple versions of an element in a diff: #{@response.body}"
+
+ get :download, :id => changeset_id
+ assert_response :success
+
+ assert_select "osmChange", 1
+ assert_select "osmChange>modify", 8
+ assert_select "osmChange>modify>node", 8
+ end
+
+ ##
+ # when we make some complex changes we get the same changes back from the
+ # diff download.
+ def test_diff_download_complex
+ basic_authorization(users(:normal_user).email, "test")
+
+ # create a temporary changeset
+ content "" +
+ "" +
+ ""
+ put :create
+ assert_response :success
+ changeset_id = @response.body.to_i
+
+ # add a diff to it
+ diff = <
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+EOF
+
+ # upload it
+ content diff
+ post :upload, :id => changeset_id
+ assert_response :success,
+ "can't upload multiple versions of an element in a diff: #{@response.body}"
+
+ get :download, :id => changeset_id
+ assert_response :success
+
+ assert_select "osmChange", 1
+ assert_select "osmChange>create", 3
+ assert_select "osmChange>delete", 1
+ assert_select "osmChange>modify", 2
+ assert_select "osmChange>create>node", 3
+ assert_select "osmChange>delete>node", 1
+ assert_select "osmChange>modify>node", 1
+ assert_select "osmChange>modify>way", 1
+ end
+
end