# Cop supports --auto-correct.
Style/IfUnlessModifier:
Exclude:
- - 'app/controllers/way_controller.rb'
+ - 'app/controllers/ways_controller.rb'
# Offense count: 70
# Cop supports --auto-correct.
# The NodeController is the RESTful interface to Node objects
-class NodeController < ApplicationController
+class NodesController < ApplicationController
require "xml/libxml"
skip_before_action :verify_authenticity_token
-class RelationController < ApplicationController
+class RelationsController < ApplicationController
require "xml/libxml"
skip_before_action :verify_authenticity_token
-class WayController < ApplicationController
+class WaysController < ApplicationController
require "xml/libxml"
skip_before_action :verify_authenticity_token
<%= render :partial => @type, :object => @feature %>
<div class='secondary-actions'>
- <%= link_to(t('browse.download_xml'), :controller => @type, :action => "read") %>
+ <%= link_to(t('browse.download_xml'), :controller => @type.pluralize, :action => "read") %>
·
<%= link_to(t('browse.view_history'), :action => "#{@type}_history") %>
</div>
post "changeset/comment/:id/hide" => "changeset#hide_comment", :as => :changeset_comment_hide, :id => /\d+/
post "changeset/comment/:id/unhide" => "changeset#unhide_comment", :as => :changeset_comment_unhide, :id => /\d+/
- put "node/create" => "node#create"
- get "node/:id/ways" => "way#ways_for_node", :id => /\d+/
- get "node/:id/relations" => "relation#relations_for_node", :id => /\d+/
+ put "node/create" => "nodes#create"
+ get "node/:id/ways" => "ways#ways_for_node", :id => /\d+/
+ get "node/:id/relations" => "relations#relations_for_node", :id => /\d+/
get "node/:id/history" => "old_node#history", :id => /\d+/
post "node/:id/:version/redact" => "old_node#redact", :version => /\d+/, :id => /\d+/
get "node/:id/:version" => "old_node#version", :id => /\d+/, :version => /\d+/
- get "node/:id" => "node#read", :id => /\d+/
- put "node/:id" => "node#update", :id => /\d+/
- delete "node/:id" => "node#delete", :id => /\d+/
- get "nodes" => "node#nodes"
+ get "node/:id" => "nodes#read", :id => /\d+/
+ put "node/:id" => "nodes#update", :id => /\d+/
+ delete "node/:id" => "nodes#delete", :id => /\d+/
+ get "nodes" => "nodes#nodes"
- put "way/create" => "way#create"
+ put "way/create" => "ways#create"
get "way/:id/history" => "old_way#history", :id => /\d+/
- get "way/:id/full" => "way#full", :id => /\d+/
- get "way/:id/relations" => "relation#relations_for_way", :id => /\d+/
+ get "way/:id/full" => "ways#full", :id => /\d+/
+ get "way/:id/relations" => "relations#relations_for_way", :id => /\d+/
post "way/:id/:version/redact" => "old_way#redact", :version => /\d+/, :id => /\d+/
get "way/:id/:version" => "old_way#version", :id => /\d+/, :version => /\d+/
- get "way/:id" => "way#read", :id => /\d+/
- put "way/:id" => "way#update", :id => /\d+/
- delete "way/:id" => "way#delete", :id => /\d+/
- get "ways" => "way#ways"
+ get "way/:id" => "ways#read", :id => /\d+/
+ put "way/:id" => "ways#update", :id => /\d+/
+ delete "way/:id" => "ways#delete", :id => /\d+/
+ get "ways" => "ways#ways"
- put "relation/create" => "relation#create"
- get "relation/:id/relations" => "relation#relations_for_relation", :id => /\d+/
+ put "relation/create" => "relations#create"
+ get "relation/:id/relations" => "relations#relations_for_relation", :id => /\d+/
get "relation/:id/history" => "old_relation#history", :id => /\d+/
- get "relation/:id/full" => "relation#full", :id => /\d+/
+ get "relation/:id/full" => "relations#full", :id => /\d+/
post "relation/:id/:version/redact" => "old_relation#redact", :version => /\d+/, :id => /\d+/
get "relation/:id/:version" => "old_relation#version", :id => /\d+/, :version => /\d+/
- get "relation/:id" => "relation#read", :id => /\d+/
- put "relation/:id" => "relation#update", :id => /\d+/
- delete "relation/:id" => "relation#delete", :id => /\d+/
- get "relations" => "relation#relations"
+ get "relation/:id" => "relations#read", :id => /\d+/
+ put "relation/:id" => "relations#update", :id => /\d+/
+ delete "relation/:id" => "relations#delete", :id => /\d+/
+ get "relations" => "relations#relations"
get "map" => "api#map"
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."
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."
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."
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
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
# 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"
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,
# 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
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,
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)
# 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)
# 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)
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
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