Test some missing cases in the way controller

This commit is contained in:
Tom Hughes 2015-03-08 18:01:19 +00:00
parent f8de0c1811
commit 51c5be98f7
4 changed files with 195 additions and 24 deletions

View file

@ -43,6 +43,7 @@ class NodeController < ApplicationController
unless new_node && new_node.id == node.id
fail OSM::APIBadUserInput.new("The id in the url (#{node.id}) is not the same as provided in the xml (#{new_node.id})")
end
node.update_from(new_node, @user)
render :text => node.version.to_s, :content_type => "text/plain"
end

View file

@ -14,14 +14,9 @@ class RelationController < ApplicationController
relation = Relation.from_xml(request.raw_post, true)
# We assume that an exception has been thrown if there was an error
# generating the relation
# if relation
# Assume that Relation.from_xml has thrown an exception if there is an error parsing the xml
relation.create_with_history @user
render :text => relation.id.to_s, :content_type => "text/plain"
# else
# render :text => "Couldn't get turn the input into a relation.", :status => :bad_request
# end
end
def read
@ -40,12 +35,12 @@ class RelationController < ApplicationController
relation = Relation.find(params[:id])
new_relation = Relation.from_xml(request.raw_post)
if new_relation && new_relation.id == relation.id
relation.update_from new_relation, @user
render :text => relation.version.to_s, :content_type => "text/plain"
else
render :text => "", :status => :bad_request
unless new_relation && new_relation.id == relation.id
fail OSM::APIBadUserInput.new("The id in the url (#{relation.id}) is not the same as provided in the xml (#{new_relation.id})")
end
relation.update_from new_relation, @user
render :text => relation.version.to_s, :content_type => "text/plain"
end
def delete

View file

@ -14,12 +14,9 @@ class WayController < ApplicationController
way = Way.from_xml(request.raw_post, true)
if way
way.create_with_history @user
render :text => way.id.to_s, :content_type => "text/plain"
else
render :text => "", :status => :bad_request
end
# Assume that Way.from_xml has thrown an exception if there is an error parsing the xml
way.create_with_history @user
render :text => way.id.to_s, :content_type => "text/plain"
end
def read
@ -38,12 +35,12 @@ class WayController < ApplicationController
way = Way.find(params[:id])
new_way = Way.from_xml(request.raw_post)
if new_way && new_way.id == way.id
way.update_from(new_way, @user)
render :text => way.version.to_s, :content_type => "text/plain"
else
render :text => "", :status => :bad_request
unless new_way && new_way.id == way.id
fail OSM::APIBadUserInput.new("The id in the url (#{way.id}) is not the same as provided in the xml (#{new_way.id})")
end
way.update_from(new_way, @user)
render :text => way.version.to_s, :content_type => "text/plain"
end
# This is the API call to delete a way