]> git.openstreetmap.org Git - rails.git/commitdiff
Pluralize nodes, ways and relations controllers
authorAndy Allan <git@gravitystorm.co.uk>
Wed, 7 Nov 2018 14:53:04 +0000 (15:53 +0100)
committerAndy Allan <git@gravitystorm.co.uk>
Wed, 7 Nov 2018 14:55:26 +0000 (15:55 +0100)
13 files changed:
.rubocop_todo.yml
app/controllers/nodes_controller.rb [moved from app/controllers/node_controller.rb with 98% similarity]
app/controllers/relations_controller.rb [moved from app/controllers/relation_controller.rb with 99% similarity]
app/controllers/ways_controller.rb [moved from app/controllers/way_controller.rb with 98% similarity]
app/views/browse/feature.html.erb
config/routes.rb
test/controllers/changeset_controller_test.rb
test/controllers/nodes_controller_test.rb [moved from test/controllers/node_controller_test.rb with 98% similarity]
test/controllers/old_node_controller_test.rb
test/controllers/old_relation_controller_test.rb
test/controllers/old_way_controller_test.rb
test/controllers/relations_controller_test.rb [moved from test/controllers/relation_controller_test.rb with 98% similarity]
test/controllers/ways_controller_test.rb [moved from test/controllers/way_controller_test.rb with 98% similarity]

index 7d2c583eb73c4ebff19e52adc3367559e83757c2..e6ecfdb4aa4304567efbd8fca5bf6e37b66ae793 100644 (file)
@@ -177,7 +177,7 @@ Style/FrozenStringLiteralComment:
 # Cop supports --auto-correct.
 Style/IfUnlessModifier:
   Exclude:
-    - 'app/controllers/way_controller.rb'
+    - 'app/controllers/ways_controller.rb'
 
 # Offense count: 70
 # Cop supports --auto-correct.
similarity index 98%
rename from app/controllers/node_controller.rb
rename to app/controllers/nodes_controller.rb
index 84b814a34529fae1cd3c5be327b418e5c47a04b3..baa6d8195abd92491f57d3e1794d6adeb119ab30 100644 (file)
@@ -1,6 +1,6 @@
 # The NodeController is the RESTful interface to Node objects
 
-class NodeController < ApplicationController
+class NodesController < ApplicationController
   require "xml/libxml"
 
   skip_before_action :verify_authenticity_token
similarity index 99%
rename from app/controllers/relation_controller.rb
rename to app/controllers/relations_controller.rb
index 059fb8d7e5bc32a7dca26128a705b800c4b0c16d..b9108cea1c5fb8f72245479ea28fde4fff5eb251 100644 (file)
@@ -1,4 +1,4 @@
-class RelationController < ApplicationController
+class RelationsController < ApplicationController
   require "xml/libxml"
 
   skip_before_action :verify_authenticity_token
similarity index 98%
rename from app/controllers/way_controller.rb
rename to app/controllers/ways_controller.rb
index e48073e10063073cfb72a28756d074efa0407403..39129ebf3486494f9be7bf76f036747c86c03bf4 100644 (file)
@@ -1,4 +1,4 @@
-class WayController < ApplicationController
+class WaysController < ApplicationController
   require "xml/libxml"
 
   skip_before_action :verify_authenticity_token
index 38657f4d1fb8f976868bb375b94e0feb206b7088..c3fadbe312e26a516fcb2d623f9bc3cf0a48dc75 100644 (file)
@@ -8,7 +8,7 @@
 <%= 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") %>
   &middot;
   <%= link_to(t('browse.view_history'), :action => "#{@type}_history") %>
 </div>
index 7d9c8dbec9f5778d7b61ff602b9275b62baf281c..235ffdba3b23152630fe602ae3250c5614141ec2 100644 (file)
@@ -20,38 +20,38 @@ OpenStreetMap::Application.routes.draw do
     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"
 
index fdb689978f7fc1cebbc9dad700d81457204af10b..472ebb25942c70e689cdc12c99a0bf4588bf42ef 100644 (file)
@@ -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
similarity index 98%
rename from test/controllers/node_controller_test.rb
rename to test/controllers/nodes_controller_test.rb
index 5f737f798a57c26a0a102739bfe62a013baa2ed7..3cd4244e14e828d6d743712c76f32779b78a401c 100644 (file)
@@ -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
 
index 346634f7d42d8b4f458b1f183567d58f9a3ca2ac..0d8db0589e30e27fc94cf174574e0e92bb6765da 100644 (file)
@@ -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)
index be91962f8fff776af17f1a1049503eeb9d5bc32d..c6f43dbdc29d5f3a52bfa5174d71156a32b741ae 100644 (file)
@@ -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)
index 1fff791877764d777990a205d56afb4dccf0f431..168ce87ddc9f8fdc0a32fc868f7f0cb003af75a0 100644 (file)
@@ -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)
similarity index 98%
rename from test/controllers/relation_controller_test.rb
rename to test/controllers/relations_controller_test.rb
index 8a7e8b2fe2b6bcf212c804e19ace3df7475e8efd..be0f6c1d7a3901525fd1bd059bf0f99a3173802a 100644 (file)
@@ -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
 
similarity index 98%
rename from test/controllers/way_controller_test.rb
rename to test/controllers/ways_controller_test.rb
index 3d466de8bbfca3893c9182173b7255c8f1f81e8b..1199e5d941b94ed290a39d985e2157ff93ed9eae 100644 (file)
@@ -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