X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/2ad75d72af79fe03a31e4a9a750604d90b4b9ffa..b6c2a3936350e52cdd5f4900d5752ed326804e09:/test/controllers/api/relations_controller_test.rb?ds=sidebyside diff --git a/test/controllers/api/relations_controller_test.rb b/test/controllers/api/relations_controller_test.rb index efe17f885..5147d851f 100644 --- a/test/controllers/api/relations_controller_test.rb +++ b/test/controllers/api/relations_controller_test.rb @@ -14,7 +14,7 @@ module Api { :controller => "api/relations", :action => "index", :format => "json" } ) assert_routing( - { :path => "/api/0.6/relation/create", :method => :put }, + { :path => "/api/0.6/relations", :method => :post }, { :controller => "api/relations", :action => "create" } ) assert_routing( @@ -66,6 +66,11 @@ module Api { :path => "/api/0.6/relation/1/relations.json", :method => :get }, { :controller => "api/relations", :action => "relations_for_relation", :id => "1", :format => "json" } ) + + assert_recognizes( + { :controller => "api/relations", :action => "create" }, + { :path => "/api/0.6/relation/create", :method => :put } + ) end ## @@ -225,7 +230,7 @@ module Api # create an relation without members xml = "" - put relation_create_path, :params => xml, :headers => auth_header + post api_relations_path, :params => xml, :headers => auth_header # hope for forbidden, due to user assert_response :forbidden, "relation upload should have failed with forbidden" @@ -236,7 +241,7 @@ module Api xml = "" \ "" \ "" - put relation_create_path, :params => xml, :headers => auth_header + post api_relations_path, :params => xml, :headers => auth_header # hope for forbidden due to user assert_response :forbidden, "relation upload did not return forbidden status" @@ -246,7 +251,7 @@ module Api # need a role attribute to be included xml = "" \ "" - put relation_create_path, :params => xml, :headers => auth_header + post api_relations_path, :params => xml, :headers => auth_header # hope for forbidden due to user assert_response :forbidden, "relation upload did not return forbidden status" @@ -257,7 +262,7 @@ module Api "" \ "" \ "" - put relation_create_path, :params => xml, :headers => auth_header + post api_relations_path, :params => xml, :headers => auth_header # hope for forbidden, due to user assert_response :forbidden, "relation upload did not return success status" @@ -267,7 +272,7 @@ module Api # create an relation without members xml = "" - put relation_create_path, :params => xml, :headers => auth_header + post api_relations_path, :params => xml, :headers => auth_header # hope for success assert_response :success, "relation upload did not return success status" @@ -295,7 +300,7 @@ module Api xml = "" \ "" \ "" - put relation_create_path, :params => xml, :headers => auth_header + post api_relations_path, :params => xml, :headers => auth_header # hope for success assert_response :success, "relation upload did not return success status" @@ -323,7 +328,7 @@ module Api # need a role attribute to be included xml = "" \ "" - put relation_create_path, :params => xml, :headers => auth_header + post api_relations_path, :params => xml, :headers => auth_header # hope for success assert_response :success, "relation upload did not return success status" @@ -352,7 +357,7 @@ module Api "" \ "" \ "" - put relation_create_path, :params => xml, :headers => auth_header + post api_relations_path, :params => xml, :headers => auth_header # hope for success assert_response :success, "relation upload did not return success status" @@ -472,7 +477,7 @@ module Api xml = "" \ "" \ "" - put relation_create_path, :params => xml, :headers => auth_header + post api_relations_path, :params => xml, :headers => auth_header # expect failure assert_response :precondition_failed, "relation upload with invalid node did not return 'precondition failed'" @@ -493,7 +498,7 @@ module Api xml = "" \ "" \ "" - put relation_create_path, :params => xml, :headers => auth_header + post api_relations_path, :params => xml, :headers => auth_header # expect failure assert_response :bad_request assert_match(/Cannot parse valid relation from xml string/, @response.body) @@ -757,7 +762,7 @@ module Api OSM doc = XML::Parser.string(doc_str).parse - put relation_create_path, :params => doc.to_s, :headers => auth_header + post api_relations_path, :params => doc.to_s, :headers => auth_header assert_response :success, "can't create a relation: #{@response.body}" relation_id = @response.body.to_i @@ -818,13 +823,13 @@ module Api ## First try with the private user auth_header = bearer_authorization_header private_user - put relation_create_path, :params => doc.to_s, :headers => auth_header + post api_relations_path, :params => doc.to_s, :headers => auth_header assert_response :forbidden ## Now try with the public user auth_header = bearer_authorization_header user - put relation_create_path, :params => doc.to_s, :headers => auth_header + post api_relations_path, :params => doc.to_s, :headers => auth_header assert_response :success, "can't create a relation: #{@response.body}" relation_id = @response.body.to_i @@ -857,7 +862,7 @@ module Api doc = XML::Parser.string(doc_str).parse auth_header = bearer_authorization_header user - put relation_create_path, :params => doc.to_s, :headers => auth_header + post api_relations_path, :params => doc.to_s, :headers => auth_header assert_response :success, "can't create a relation: #{@response.body}" relation_id = @response.body.to_i @@ -929,7 +934,7 @@ module Api "" \ "" \ "" - put relation_create_path, :params => xml, :headers => auth_header + post api_relations_path, :params => xml, :headers => auth_header assert_response :success, "relation create did not return success status" # get the id of the relation we created @@ -953,7 +958,7 @@ module Api "" \ "" \ "" - put relation_create_path, :params => xml, :headers => auth_header + post api_relations_path, :params => xml, :headers => auth_header assert_response :too_many_requests, "relation create did not hit rate limit" end @@ -989,7 +994,7 @@ module Api "" \ "" \ "" - put relation_create_path, :params => xml, :headers => auth_header + post api_relations_path, :params => xml, :headers => auth_header assert_response :success, "relation create did not return success status" # get the id of the relation we created @@ -1013,7 +1018,7 @@ module Api "" \ "" \ "" - put relation_create_path, :params => xml, :headers => auth_header + post api_relations_path, :params => xml, :headers => auth_header assert_response :too_many_requests, "relation create did not hit rate limit" end