From e85c56d151a88a69f878ce4ed5bfdf4bbe695fbb Mon Sep 17 00:00:00 2001 From: Andy Allan Date: Wed, 7 Nov 2018 16:02:22 +0100 Subject: [PATCH 1/1] Pluralize old_ controllers --- ...e_controller.rb => old_nodes_controller.rb} | 2 +- ...ntroller.rb => old_relations_controller.rb} | 2 +- ...ay_controller.rb => old_ways_controller.rb} | 2 +- app/views/browse/history.html.erb | 2 +- config/routes.rb | 18 +++++++++--------- ...er_test.rb => old_nodes_controller_test.rb} | 9 ++++----- ...est.rb => old_relations_controller_test.rb} | 9 ++++----- ...ler_test.rb => old_ways_controller_test.rb} | 9 ++++----- test/controllers/relations_controller_test.rb | 6 +++--- 9 files changed, 28 insertions(+), 31 deletions(-) rename app/controllers/{old_node_controller.rb => old_nodes_controller.rb} (84%) rename app/controllers/{old_relation_controller.rb => old_relations_controller.rb} (83%) rename app/controllers/{old_way_controller.rb => old_ways_controller.rb} (84%) rename test/controllers/{old_node_controller_test.rb => old_nodes_controller_test.rb} (98%) rename test/controllers/{old_relation_controller_test.rb => old_relations_controller_test.rb} (97%) rename test/controllers/{old_way_controller_test.rb => old_ways_controller_test.rb} (97%) diff --git a/app/controllers/old_node_controller.rb b/app/controllers/old_nodes_controller.rb similarity index 84% rename from app/controllers/old_node_controller.rb rename to app/controllers/old_nodes_controller.rb index a32e299fe..43c8b6b75 100644 --- a/app/controllers/old_node_controller.rb +++ b/app/controllers/old_nodes_controller.rb @@ -1,4 +1,4 @@ -class OldNodeController < OldController +class OldNodesController < OldController private def lookup_old_element diff --git a/app/controllers/old_relation_controller.rb b/app/controllers/old_relations_controller.rb similarity index 83% rename from app/controllers/old_relation_controller.rb rename to app/controllers/old_relations_controller.rb index 78eca324c..40c450376 100644 --- a/app/controllers/old_relation_controller.rb +++ b/app/controllers/old_relations_controller.rb @@ -1,4 +1,4 @@ -class OldRelationController < OldController +class OldRelationsController < OldController private def lookup_old_element diff --git a/app/controllers/old_way_controller.rb b/app/controllers/old_ways_controller.rb similarity index 84% rename from app/controllers/old_way_controller.rb rename to app/controllers/old_ways_controller.rb index 1daab997a..c8185c633 100644 --- a/app/controllers/old_way_controller.rb +++ b/app/controllers/old_ways_controller.rb @@ -1,4 +1,4 @@ -class OldWayController < OldController +class OldWaysController < OldController private def lookup_old_element diff --git a/app/views/browse/history.html.erb b/app/views/browse/history.html.erb index 5f5dd4db3..6cf0a3569 100644 --- a/app/views/browse/history.html.erb +++ b/app/views/browse/history.html.erb @@ -8,7 +8,7 @@ <%= render :partial => @type, :collection => @feature.send("old_#{@type}s").reverse %>
- <%= link_to(t('browse.download_xml'), :controller => "old_#{@type}", :action => "history") %> + <%= link_to(t('browse.download_xml'), :controller => "old_#{@type.pluralize}", :action => "history") %> · <%= link_to(t('browse.view_details'), :action => @type) %>
diff --git a/config/routes.rb b/config/routes.rb index 235ffdba3..71fcfd57d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -23,20 +23,20 @@ OpenStreetMap::Application.routes.draw do 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/history" => "old_nodes#history", :id => /\d+/ + post "node/:id/:version/redact" => "old_nodes#redact", :version => /\d+/, :id => /\d+/ + get "node/:id/:version" => "old_nodes#version", :id => /\d+/, :version => /\d+/ 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" => "ways#create" - get "way/:id/history" => "old_way#history", :id => /\d+/ + get "way/:id/history" => "old_ways#history", :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+/ + post "way/:id/:version/redact" => "old_ways#redact", :version => /\d+/, :id => /\d+/ + get "way/:id/:version" => "old_ways#version", :id => /\d+/, :version => /\d+/ get "way/:id" => "ways#read", :id => /\d+/ put "way/:id" => "ways#update", :id => /\d+/ delete "way/:id" => "ways#delete", :id => /\d+/ @@ -44,10 +44,10 @@ OpenStreetMap::Application.routes.draw do 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/history" => "old_relations#history", :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+/ + post "relation/:id/:version/redact" => "old_relations#redact", :version => /\d+/, :id => /\d+/ + get "relation/:id/:version" => "old_relations#version", :id => /\d+/, :version => /\d+/ get "relation/:id" => "relations#read", :id => /\d+/ put "relation/:id" => "relations#update", :id => /\d+/ delete "relation/:id" => "relations#delete", :id => /\d+/ diff --git a/test/controllers/old_node_controller_test.rb b/test/controllers/old_nodes_controller_test.rb similarity index 98% rename from test/controllers/old_node_controller_test.rb rename to test/controllers/old_nodes_controller_test.rb index 0d8db0589..2568cbfd8 100644 --- a/test/controllers/old_node_controller_test.rb +++ b/test/controllers/old_nodes_controller_test.rb @@ -1,7 +1,6 @@ require "test_helper" -require "old_node_controller" -class OldNodeControllerTest < ActionController::TestCase +class OldNodesControllerTest < ActionController::TestCase # # TODO: test history # @@ -11,15 +10,15 @@ class OldNodeControllerTest < ActionController::TestCase def test_routes assert_routing( { :path => "/api/0.6/node/1/history", :method => :get }, - { :controller => "old_node", :action => "history", :id => "1" } + { :controller => "old_nodes", :action => "history", :id => "1" } ) assert_routing( { :path => "/api/0.6/node/1/2", :method => :get }, - { :controller => "old_node", :action => "version", :id => "1", :version => "2" } + { :controller => "old_nodes", :action => "version", :id => "1", :version => "2" } ) assert_routing( { :path => "/api/0.6/node/1/2/redact", :method => :post }, - { :controller => "old_node", :action => "redact", :id => "1", :version => "2" } + { :controller => "old_nodes", :action => "redact", :id => "1", :version => "2" } ) end diff --git a/test/controllers/old_relation_controller_test.rb b/test/controllers/old_relations_controller_test.rb similarity index 97% rename from test/controllers/old_relation_controller_test.rb rename to test/controllers/old_relations_controller_test.rb index c6f43dbdc..51e6c565a 100644 --- a/test/controllers/old_relation_controller_test.rb +++ b/test/controllers/old_relations_controller_test.rb @@ -1,21 +1,20 @@ require "test_helper" -require "old_relation_controller" -class OldRelationControllerTest < ActionController::TestCase +class OldRelationsControllerTest < ActionController::TestCase ## # test all routes which lead to this controller def test_routes assert_routing( { :path => "/api/0.6/relation/1/history", :method => :get }, - { :controller => "old_relation", :action => "history", :id => "1" } + { :controller => "old_relations", :action => "history", :id => "1" } ) assert_routing( { :path => "/api/0.6/relation/1/2", :method => :get }, - { :controller => "old_relation", :action => "version", :id => "1", :version => "2" } + { :controller => "old_relations", :action => "version", :id => "1", :version => "2" } ) assert_routing( { :path => "/api/0.6/relation/1/2/redact", :method => :post }, - { :controller => "old_relation", :action => "redact", :id => "1", :version => "2" } + { :controller => "old_relations", :action => "redact", :id => "1", :version => "2" } ) end diff --git a/test/controllers/old_way_controller_test.rb b/test/controllers/old_ways_controller_test.rb similarity index 97% rename from test/controllers/old_way_controller_test.rb rename to test/controllers/old_ways_controller_test.rb index 168ce87dd..0dd2d5e3c 100644 --- a/test/controllers/old_way_controller_test.rb +++ b/test/controllers/old_ways_controller_test.rb @@ -1,21 +1,20 @@ require "test_helper" -require "old_way_controller" -class OldWayControllerTest < ActionController::TestCase +class OldWaysControllerTest < ActionController::TestCase ## # test all routes which lead to this controller def test_routes assert_routing( { :path => "/api/0.6/way/1/history", :method => :get }, - { :controller => "old_way", :action => "history", :id => "1" } + { :controller => "old_ways", :action => "history", :id => "1" } ) assert_routing( { :path => "/api/0.6/way/1/2", :method => :get }, - { :controller => "old_way", :action => "version", :id => "1", :version => "2" } + { :controller => "old_ways", :action => "version", :id => "1", :version => "2" } ) assert_routing( { :path => "/api/0.6/way/1/2/redact", :method => :post }, - { :controller => "old_way", :action => "redact", :id => "1", :version => "2" } + { :controller => "old_ways", :action => "redact", :id => "1", :version => "2" } ) end diff --git a/test/controllers/relations_controller_test.rb b/test/controllers/relations_controller_test.rb index be0f6c1d7..1613fbf7a 100644 --- a/test/controllers/relations_controller_test.rb +++ b/test/controllers/relations_controller_test.rb @@ -784,7 +784,7 @@ OSM check_ordering(doc, @response.body) # check the ordering in the history tables: - with_controller(OldRelationController.new) do + with_controller(OldRelationsController.new) do get :version, :params => { :id => relation_id, :version => 2 } assert_response :success, "can't read back version 2 of the relation #{relation_id}" check_ordering(doc, @response.body) @@ -867,7 +867,7 @@ OSM check_ordering(doc, @response.body) # check the ordering in the history tables: - with_controller(OldRelationController.new) do + with_controller(OldRelationsController.new) do get :version, :params => { :id => relation_id, :version => 1 } assert_response :success, "can't read back version 1 of the relation: #{@response.body}" check_ordering(doc, @response.body) @@ -981,7 +981,7 @@ OSM if ver.nil? get :read, :params => { :id => id } else - with_controller(OldRelationController.new) do + with_controller(OldRelationsController.new) do get :version, :params => { :id => id, :version => ver } end end -- 2.43.2