Pluralize old_ controllers

This commit is contained in:
Andy Allan 2018-11-07 16:02:22 +01:00
parent 05117aa928
commit e85c56d151
9 changed files with 28 additions and 31 deletions

View file

@ -1,4 +1,4 @@
class OldNodeController < OldController
class OldNodesController < OldController
private
def lookup_old_element

View file

@ -1,4 +1,4 @@
class OldRelationController < OldController
class OldRelationsController < OldController
private
def lookup_old_element

View file

@ -1,4 +1,4 @@
class OldWayController < OldController
class OldWaysController < OldController
private
def lookup_old_element

View file

@ -8,7 +8,7 @@
<%= render :partial => @type, :collection => @feature.send("old_#{@type}s").reverse %>
<div class='secondary-actions'>
<%= link_to(t('browse.download_xml'), :controller => "old_#{@type}", :action => "history") %>
<%= link_to(t('browse.download_xml'), :controller => "old_#{@type.pluralize}", :action => "history") %>
&middot;
<%= link_to(t('browse.view_details'), :action => @type) %>
</div>

View file

@ -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+/

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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