Pluralize nodes, ways and relations controllers
This commit is contained in:
parent
9bd634405b
commit
05117aa928
13 changed files with 60 additions and 62 deletions
|
@ -1528,7 +1528,7 @@ CHANGESET
|
|||
changeset_id = @response.body.to_i
|
||||
|
||||
# add a single node to it
|
||||
with_controller(NodeController.new) do
|
||||
with_controller(NodesController.new) do
|
||||
content "<osm><node lon='1' lat='2' changeset='#{changeset_id}'/></osm>"
|
||||
put :create
|
||||
assert_response :success, "Couldn't create node."
|
||||
|
@ -1543,7 +1543,7 @@ CHANGESET
|
|||
assert_select "osm>changeset[max_lat='2.0000000']", 1
|
||||
|
||||
# add another node to it
|
||||
with_controller(NodeController.new) do
|
||||
with_controller(NodesController.new) do
|
||||
content "<osm><node lon='2' lat='1' changeset='#{changeset_id}'/></osm>"
|
||||
put :create
|
||||
assert_response :success, "Couldn't create second node."
|
||||
|
@ -1558,7 +1558,7 @@ CHANGESET
|
|||
assert_select "osm>changeset[max_lat='2.0000000']", 1
|
||||
|
||||
# add (delete) a way to it, which contains a point at (3,3)
|
||||
with_controller(WayController.new) do
|
||||
with_controller(WaysController.new) do
|
||||
content update_changeset(way.to_xml, changeset_id)
|
||||
put :delete, :params => { :id => way.id }
|
||||
assert_response :success, "Couldn't delete a way."
|
||||
|
@ -1838,7 +1838,7 @@ CHANGESET
|
|||
changeset.num_changes = Changeset::MAX_ELEMENTS - offset
|
||||
changeset.save!
|
||||
|
||||
with_controller(NodeController.new) do
|
||||
with_controller(NodesController.new) do
|
||||
# create a new node
|
||||
content "<osm><node changeset='#{cs_id}' lat='0.0' lon='0.0'/></osm>"
|
||||
put :create
|
||||
|
|
|
@ -1,28 +1,28 @@
|
|||
require "test_helper"
|
||||
|
||||
class NodeControllerTest < ActionController::TestCase
|
||||
class NodesControllerTest < ActionController::TestCase
|
||||
##
|
||||
# test all routes which lead to this controller
|
||||
def test_routes
|
||||
assert_routing(
|
||||
{ :path => "/api/0.6/node/create", :method => :put },
|
||||
{ :controller => "node", :action => "create" }
|
||||
{ :controller => "nodes", :action => "create" }
|
||||
)
|
||||
assert_routing(
|
||||
{ :path => "/api/0.6/node/1", :method => :get },
|
||||
{ :controller => "node", :action => "read", :id => "1" }
|
||||
{ :controller => "nodes", :action => "read", :id => "1" }
|
||||
)
|
||||
assert_routing(
|
||||
{ :path => "/api/0.6/node/1", :method => :put },
|
||||
{ :controller => "node", :action => "update", :id => "1" }
|
||||
{ :controller => "nodes", :action => "update", :id => "1" }
|
||||
)
|
||||
assert_routing(
|
||||
{ :path => "/api/0.6/node/1", :method => :delete },
|
||||
{ :controller => "node", :action => "delete", :id => "1" }
|
||||
{ :controller => "nodes", :action => "delete", :id => "1" }
|
||||
)
|
||||
assert_routing(
|
||||
{ :path => "/api/0.6/nodes", :method => :get },
|
||||
{ :controller => "node", :action => "nodes" }
|
||||
{ :controller => "nodes", :action => "nodes" }
|
||||
)
|
||||
end
|
||||
|
|
@ -59,7 +59,7 @@ class OldNodeControllerTest < ActionController::TestCase
|
|||
# move the node somewhere else
|
||||
xml_node["lat"] = precision(rand * 180 - 90).to_s
|
||||
xml_node["lon"] = precision(rand * 360 - 180).to_s
|
||||
with_controller(NodeController.new) do
|
||||
with_controller(NodesController.new) do
|
||||
content xml_doc
|
||||
put :update, :params => { :id => nodeid }
|
||||
assert_response :forbidden, "Should have rejected node update"
|
||||
|
@ -75,7 +75,7 @@ class OldNodeControllerTest < ActionController::TestCase
|
|||
xml_tag["k"] = random_string
|
||||
xml_tag["v"] = random_string
|
||||
xml_node << xml_tag
|
||||
with_controller(NodeController.new) do
|
||||
with_controller(NodesController.new) do
|
||||
content xml_doc
|
||||
put :update, :params => { :id => nodeid }
|
||||
assert_response :forbidden,
|
||||
|
@ -109,7 +109,7 @@ class OldNodeControllerTest < ActionController::TestCase
|
|||
# move the node somewhere else
|
||||
xml_node["lat"] = precision(rand * 180 - 90).to_s
|
||||
xml_node["lon"] = precision(rand * 360 - 180).to_s
|
||||
with_controller(NodeController.new) do
|
||||
with_controller(NodesController.new) do
|
||||
content xml_doc
|
||||
put :update, :params => { :id => nodeid }
|
||||
assert_response :success
|
||||
|
@ -125,7 +125,7 @@ class OldNodeControllerTest < ActionController::TestCase
|
|||
xml_tag["k"] = random_string
|
||||
xml_tag["v"] = random_string
|
||||
xml_node << xml_tag
|
||||
with_controller(NodeController.new) do
|
||||
with_controller(NodesController.new) do
|
||||
content xml_doc
|
||||
put :update, :params => { :id => nodeid }
|
||||
assert_response :success,
|
||||
|
@ -390,7 +390,7 @@ class OldNodeControllerTest < ActionController::TestCase
|
|||
|
||||
def check_current_version(node_id)
|
||||
# get the current version of the node
|
||||
current_node = with_controller(NodeController.new) do
|
||||
current_node = with_controller(NodesController.new) do
|
||||
get :read, :params => { :id => node_id }
|
||||
assert_response :success, "cant get current node #{node_id}"
|
||||
Node.from_xml(@response.body)
|
||||
|
|
|
@ -225,7 +225,7 @@ class OldRelationControllerTest < ActionController::TestCase
|
|||
# version which we're getting from the versions call.
|
||||
def check_current_version(relation_id)
|
||||
# get the current version
|
||||
current_relation = with_controller(RelationController.new) do
|
||||
current_relation = with_controller(RelationsController.new) do
|
||||
get :read, :params => { :id => relation_id }
|
||||
assert_response :success, "can't get current relation #{relation_id}"
|
||||
Relation.from_xml(@response.body)
|
||||
|
|
|
@ -265,7 +265,7 @@ class OldWayControllerTest < ActionController::TestCase
|
|||
# version which we're getting from the versions call.
|
||||
def check_current_version(way_id)
|
||||
# get the current version
|
||||
current_way = with_controller(WayController.new) do
|
||||
current_way = with_controller(WaysController.new) do
|
||||
get :read, :params => { :id => way_id }
|
||||
assert_response :success, "can't get current way #{way_id}"
|
||||
Way.from_xml(@response.body)
|
||||
|
|
|
@ -1,46 +1,45 @@
|
|||
require "test_helper"
|
||||
require "relation_controller"
|
||||
|
||||
class RelationControllerTest < ActionController::TestCase
|
||||
class RelationsControllerTest < ActionController::TestCase
|
||||
##
|
||||
# test all routes which lead to this controller
|
||||
def test_routes
|
||||
assert_routing(
|
||||
{ :path => "/api/0.6/relation/create", :method => :put },
|
||||
{ :controller => "relation", :action => "create" }
|
||||
{ :controller => "relations", :action => "create" }
|
||||
)
|
||||
assert_routing(
|
||||
{ :path => "/api/0.6/relation/1/full", :method => :get },
|
||||
{ :controller => "relation", :action => "full", :id => "1" }
|
||||
{ :controller => "relations", :action => "full", :id => "1" }
|
||||
)
|
||||
assert_routing(
|
||||
{ :path => "/api/0.6/relation/1", :method => :get },
|
||||
{ :controller => "relation", :action => "read", :id => "1" }
|
||||
{ :controller => "relations", :action => "read", :id => "1" }
|
||||
)
|
||||
assert_routing(
|
||||
{ :path => "/api/0.6/relation/1", :method => :put },
|
||||
{ :controller => "relation", :action => "update", :id => "1" }
|
||||
{ :controller => "relations", :action => "update", :id => "1" }
|
||||
)
|
||||
assert_routing(
|
||||
{ :path => "/api/0.6/relation/1", :method => :delete },
|
||||
{ :controller => "relation", :action => "delete", :id => "1" }
|
||||
{ :controller => "relations", :action => "delete", :id => "1" }
|
||||
)
|
||||
assert_routing(
|
||||
{ :path => "/api/0.6/relations", :method => :get },
|
||||
{ :controller => "relation", :action => "relations" }
|
||||
{ :controller => "relations", :action => "relations" }
|
||||
)
|
||||
|
||||
assert_routing(
|
||||
{ :path => "/api/0.6/node/1/relations", :method => :get },
|
||||
{ :controller => "relation", :action => "relations_for_node", :id => "1" }
|
||||
{ :controller => "relations", :action => "relations_for_node", :id => "1" }
|
||||
)
|
||||
assert_routing(
|
||||
{ :path => "/api/0.6/way/1/relations", :method => :get },
|
||||
{ :controller => "relation", :action => "relations_for_way", :id => "1" }
|
||||
{ :controller => "relations", :action => "relations_for_way", :id => "1" }
|
||||
)
|
||||
assert_routing(
|
||||
{ :path => "/api/0.6/relation/1/relations", :method => :get },
|
||||
{ :controller => "relation", :action => "relations_for_relation", :id => "1" }
|
||||
{ :controller => "relations", :action => "relations_for_relation", :id => "1" }
|
||||
)
|
||||
end
|
||||
|
|
@ -1,33 +1,32 @@
|
|||
require "test_helper"
|
||||
require "way_controller"
|
||||
|
||||
class WayControllerTest < ActionController::TestCase
|
||||
class WaysControllerTest < ActionController::TestCase
|
||||
##
|
||||
# test all routes which lead to this controller
|
||||
def test_routes
|
||||
assert_routing(
|
||||
{ :path => "/api/0.6/way/create", :method => :put },
|
||||
{ :controller => "way", :action => "create" }
|
||||
{ :controller => "ways", :action => "create" }
|
||||
)
|
||||
assert_routing(
|
||||
{ :path => "/api/0.6/way/1/full", :method => :get },
|
||||
{ :controller => "way", :action => "full", :id => "1" }
|
||||
{ :controller => "ways", :action => "full", :id => "1" }
|
||||
)
|
||||
assert_routing(
|
||||
{ :path => "/api/0.6/way/1", :method => :get },
|
||||
{ :controller => "way", :action => "read", :id => "1" }
|
||||
{ :controller => "ways", :action => "read", :id => "1" }
|
||||
)
|
||||
assert_routing(
|
||||
{ :path => "/api/0.6/way/1", :method => :put },
|
||||
{ :controller => "way", :action => "update", :id => "1" }
|
||||
{ :controller => "ways", :action => "update", :id => "1" }
|
||||
)
|
||||
assert_routing(
|
||||
{ :path => "/api/0.6/way/1", :method => :delete },
|
||||
{ :controller => "way", :action => "delete", :id => "1" }
|
||||
{ :controller => "ways", :action => "delete", :id => "1" }
|
||||
)
|
||||
assert_routing(
|
||||
{ :path => "/api/0.6/ways", :method => :get },
|
||||
{ :controller => "way", :action => "ways" }
|
||||
{ :controller => "ways", :action => "ways" }
|
||||
)
|
||||
end
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue