]> git.openstreetmap.org Git - rails.git/commitdiff
Make api old element show paths resourceful
authorAnton Khorev <tony29@yandex.ru>
Sat, 8 Feb 2025 17:29:15 +0000 (20:29 +0300)
committerAnton Khorev <tony29@yandex.ru>
Sun, 9 Feb 2025 23:07:48 +0000 (02:07 +0300)
12 files changed:
app/controllers/api/old_nodes_controller.rb
app/controllers/api/old_relations_controller.rb
app/controllers/api/old_ways_controller.rb
app/views/old_elements/_actions.html.erb
config/routes.rb
test/controllers/api/old_nodes_controller_test.rb
test/controllers/api/old_relations_controller_test.rb
test/controllers/api/old_ways_controller_test.rb
test/controllers/api/relations_controller_test.rb
test/controllers/old_nodes_controller_test.rb
test/controllers/old_relations_controller_test.rb
test/controllers/old_ways_controller_test.rb

index eb6c1acf5fff1ac32f6cf13701b777cc6e68ee4f..b63761af9cfb96353cbb4dfd56d39735ab46052e 100644 (file)
@@ -3,7 +3,7 @@ module Api
     private
 
     def lookup_old_element
-      @old_element = OldNode.find([params[:id], params[:version]])
+      @old_element = OldNode.find([params[:node_id], params[:version]])
     end
 
     def lookup_old_element_versions
index 6321b9adfb051f3748013170886fc460cc7f0b39..c065c657d1a787a4eb8b14a075b226164dcfbc74 100644 (file)
@@ -3,7 +3,7 @@ module Api
     private
 
     def lookup_old_element
-      @old_element = OldRelation.find([params[:id], params[:version]])
+      @old_element = OldRelation.find([params[:relation_id], params[:version]])
     end
 
     def lookup_old_element_versions
index 73226dee6e322cc8117f50d7bd9069d11e6afb0e..654100767f06e833c46f4ce3c400caa9f8cd3487 100644 (file)
@@ -3,7 +3,7 @@ module Api
     private
 
     def lookup_old_element
-      @old_element = OldWay.find([params[:id], params[:version]])
+      @old_element = OldWay.find([params[:way_id], params[:version]])
     end
 
     def lookup_old_element_versions
index 36a16abb4543ffb74c3a00276c5e34e9d877b932..b4d28123ce4f38be33d3e263d8a40efbce9fbd71 100644 (file)
@@ -2,7 +2,7 @@
   <%= link_to t("browse.view_details"), :controller => @type.pluralize, :action => :show %>
   <% if !@feature.redacted? %>
     &middot;
-    <%= link_to t("browse.download_xml"), :controller => "api/old_#{@type.pluralize}", :action => :show %>
+    <%= link_to t("browse.download_xml"), send(:"api_#{@type}_version_path", *@feature.id) %>
   <% elsif current_user&.moderator? %>
     &middot;
     <% if !params[:show_redactions] %>
index 0d9950d048628f9d161e8feb45eb13ef1ba4787f..54bf037cf293984488572a901710283a02d9222b 100644 (file)
@@ -30,14 +30,11 @@ OpenStreetMap::Application.routes.draw do
     post "changeset/comment/:id/hide" => "changeset_comments#destroy", :as => :changeset_comment_hide, :id => /\d+/
     post "changeset/comment/:id/unhide" => "changeset_comments#restore", :as => :changeset_comment_unhide, :id => /\d+/
 
-    post "node/:id/:version/redact" => "old_nodes#redact", :as => :node_version_redact, :version => /\d+/, :id => /\d+/
-    get "node/:id/:version" => "old_nodes#show", :as => :api_old_node, :id => /\d+/, :version => /\d+/
+    post "node/:node_id/:version/redact" => "old_nodes#redact", :as => :node_version_redact, :version => /\d+/, :node_id => /\d+/
 
-    post "way/:id/:version/redact" => "old_ways#redact", :as => :way_version_redact, :version => /\d+/, :id => /\d+/
-    get "way/:id/:version" => "old_ways#show", :as => :api_old_way, :id => /\d+/, :version => /\d+/
+    post "way/:way_id/:version/redact" => "old_ways#redact", :as => :way_version_redact, :version => /\d+/, :id => /\d+/
 
-    post "relation/:id/:version/redact" => "old_relations#redact", :as => :relation_version_redact, :version => /\d+/, :id => /\d+/
-    get "relation/:id/:version" => "old_relations#show", :as => :api_old_relation, :id => /\d+/, :version => /\d+/
+    post "relation/:relation_id/:version/redact" => "old_relations#redact", :as => :relation_version_redact, :version => /\d+/, :id => /\d+/
   end
 
   namespace :api, :path => "api/0.6" do
@@ -48,6 +45,7 @@ OpenStreetMap::Application.routes.draw do
         resources :relations, :only => :index
       end
       resources :versions, :path => "history", :controller => :old_nodes, :only => :index
+      resources :versions, :path => "", :version => /\d+/, :param => :version, :controller => :old_nodes, :only => :show
     end
     put "node/create" => "nodes#create", :as => nil
 
@@ -60,6 +58,7 @@ OpenStreetMap::Application.routes.draw do
         resources :relations, :only => :index
       end
       resources :versions, :path => "history", :controller => :old_ways, :only => :index
+      resources :versions, :path => "", :version => /\d+/, :param => :version, :controller => :old_ways, :only => :show
     end
     put "way/create" => "ways#create", :as => nil
 
@@ -72,6 +71,7 @@ OpenStreetMap::Application.routes.draw do
         resources :relations, :only => :index
       end
       resources :versions, :path => "history", :controller => :old_relations, :only => :index
+      resources :versions, :path => "", :version => /\d+/, :param => :version, :controller => :old_relations, :only => :show
     end
     put "relation/create" => "relations#create", :as => nil
 
index 2b1585be206d5101e5f1902ed2d3c66ff03798a1..8cb3abb0fde5b6e0cb04606034527ff909cd56d0 100644 (file)
@@ -15,15 +15,15 @@ module Api
       )
       assert_routing(
         { :path => "/api/0.6/node/1/2", :method => :get },
-        { :controller => "api/old_nodes", :action => "show", :id => "1", :version => "2" }
+        { :controller => "api/old_nodes", :action => "show", :node_id => "1", :version => "2" }
       )
       assert_routing(
         { :path => "/api/0.6/node/1/2.json", :method => :get },
-        { :controller => "api/old_nodes", :action => "show", :id => "1", :version => "2", :format => "json" }
+        { :controller => "api/old_nodes", :action => "show", :node_id => "1", :version => "2", :format => "json" }
       )
       assert_routing(
         { :path => "/api/0.6/node/1/2/redact", :method => :post },
-        { :controller => "api/old_nodes", :action => "redact", :id => "1", :version => "2" }
+        { :controller => "api/old_nodes", :action => "redact", :node_id => "1", :version => "2" }
       )
     end
 
@@ -77,7 +77,7 @@ module Api
     #
     ##
     # FIXME: Move this test to being an integration test since it spans multiple controllers
-    def test_version
+    def test_show
       private_user = create(:user, :data_public => false)
       private_node = create(:node, :with_history, :version => 4, :lat => 0, :lon => 0, :changeset => create(:changeset, :user => private_user))
       user = create(:user)
@@ -181,7 +181,7 @@ module Api
 
       # check all the versions
       versions.each_key do |key|
-        get api_old_node_path(nodeid, key.to_i)
+        get api_node_version_path(nodeid, key.to_i)
 
         assert_response :success,
                         "couldn't get version #{key.to_i} of node #{nodeid}"
@@ -193,13 +193,30 @@ module Api
       end
     end
 
-    def test_not_found_version
+    def test_show_not_found
       check_not_found_id_version(70000, 312344)
       check_not_found_id_version(-1, -13)
       check_not_found_id_version(create(:node).id, 24354)
       check_not_found_id_version(24356, create(:node).version)
     end
 
+    ##
+    # test that redacted nodes aren't visible, regardless of
+    # authorisation except as moderator...
+    def test_show_redacted
+      node = create(:node, :with_history, :version => 2)
+      node_v1 = node.old_nodes.find_by(:version => 1)
+      node_v1.redact!(create(:redaction))
+
+      get api_node_version_path(node_v1.node_id, node_v1.version)
+      assert_response :forbidden, "Redacted node shouldn't be visible via the version API."
+
+      # not even to a logged-in user
+      auth_header = bearer_authorization_header
+      get api_node_version_path(node_v1.node_id, node_v1.version), :headers => auth_header
+      assert_response :forbidden, "Redacted node shouldn't be visible via the version API, even when logged in."
+    end
+
     ##
     # Test that getting the current version is identical to picking
     # that version with the version URI call.
@@ -301,23 +318,6 @@ module Api
       assert_response :success, "should be OK to redact old version as moderator with write_redactions scope."
     end
 
-    ##
-    # test that redacted nodes aren't visible, regardless of
-    # authorisation except as moderator...
-    def test_version_redacted
-      node = create(:node, :with_history, :version => 2)
-      node_v1 = node.old_nodes.find_by(:version => 1)
-      node_v1.redact!(create(:redaction))
-
-      get api_old_node_path(node_v1.node_id, node_v1.version)
-      assert_response :forbidden, "Redacted node shouldn't be visible via the version API."
-
-      # not even to a logged-in user
-      auth_header = bearer_authorization_header
-      get api_old_node_path(node_v1.node_id, node_v1.version), :headers => auth_header
-      assert_response :forbidden, "Redacted node shouldn't be visible via the version API, even when logged in."
-    end
-
     ##
     # test the redaction of an old version of a node, while being
     # authorised as a moderator.
@@ -331,9 +331,9 @@ module Api
 
       # check moderator can still see the redacted data, when passing
       # the appropriate flag
-      get api_old_node_path(node_v3.node_id, node_v3.version), :headers => auth_header
+      get api_node_version_path(node_v3.node_id, node_v3.version), :headers => auth_header
       assert_response :forbidden, "After redaction, node should be gone for moderator, when flag not passed."
-      get api_old_node_path(node_v3.node_id, node_v3.version, :show_redactions => "true"), :headers => auth_header
+      get api_node_version_path(node_v3.node_id, node_v3.version, :show_redactions => "true"), :headers => auth_header
       assert_response :success, "After redaction, node should not be gone for moderator, when flag passed."
 
       # and when accessed via history
@@ -361,7 +361,7 @@ module Api
       auth_header = bearer_authorization_header
 
       # check can't see the redacted data
-      get api_old_node_path(node_v3.node_id, node_v3.version), :headers => auth_header
+      get api_node_version_path(node_v3.node_id, node_v3.version), :headers => auth_header
       assert_response :forbidden, "Redacted node shouldn't be visible via the version API."
 
       # and when accessed via history
@@ -414,7 +414,7 @@ module Api
 
       # check moderator can now see the redacted data, when not
       # passing the aspecial flag
-      get api_old_node_path(node_v1.node_id, node_v1.version), :headers => auth_header
+      get api_node_version_path(node_v1.node_id, node_v1.version), :headers => auth_header
       assert_response :success, "After unredaction, node should not be gone for moderator."
 
       # and when accessed via history
@@ -426,7 +426,7 @@ module Api
       auth_header = bearer_authorization_header
 
       # check normal user can now see the redacted data
-      get api_old_node_path(node_v1.node_id, node_v1.version), :headers => auth_header
+      get api_node_version_path(node_v1.node_id, node_v1.version), :headers => auth_header
       assert_response :success, "After unredaction, node should be visible to normal users."
 
       # and when accessed via history
@@ -445,7 +445,7 @@ module Api
     end
 
     def do_redact_node(node, redaction, headers = {})
-      get api_old_node_path(node.node_id, node.version), :headers => headers
+      get api_node_version_path(node.node_id, node.version), :headers => headers
       assert_response :success, "should be able to get version #{node.version} of node #{node.node_id}."
 
       # now redact it
@@ -462,7 +462,7 @@ module Api
       assert_not_nil current_node, "getting node #{node_id} returned nil"
 
       # get the "old" version of the node from the old_node interface
-      get api_old_node_path(node_id, current_node.version)
+      get api_node_version_path(node_id, current_node.version)
       assert_response :success, "cant get old node #{node_id}, v#{current_node.version}"
       old_node = Node.from_xml(@response.body)
 
@@ -471,7 +471,7 @@ module Api
     end
 
     def check_not_found_id_version(id, version)
-      get api_old_node_path(id, version)
+      get api_node_version_path(id, version)
       assert_response :not_found
     rescue ActionController::UrlGenerationError => e
       assert_match(/No route matches/, e.to_s)
index 506c6a1ed5314cf50cb397edfca95d052978c8e6..3eec3c87fc5177efb7e4f5baac49ec9506d947ec 100644 (file)
@@ -15,15 +15,15 @@ module Api
       )
       assert_routing(
         { :path => "/api/0.6/relation/1/2", :method => :get },
-        { :controller => "api/old_relations", :action => "show", :id => "1", :version => "2" }
+        { :controller => "api/old_relations", :action => "show", :relation_id => "1", :version => "2" }
       )
       assert_routing(
         { :path => "/api/0.6/relation/1/2.json", :method => :get },
-        { :controller => "api/old_relations", :action => "show", :id => "1", :version => "2", :format => "json" }
+        { :controller => "api/old_relations", :action => "show", :relation_id => "1", :version => "2", :format => "json" }
       )
       assert_routing(
         { :path => "/api/0.6/relation/1/2/redact", :method => :post },
-        { :controller => "api/old_relations", :action => "redact", :id => "1", :version => "2" }
+        { :controller => "api/old_relations", :action => "redact", :relation_id => "1", :version => "2" }
       )
     end
 
@@ -73,6 +73,57 @@ module Api
                     "redacted relation #{relation_v1.relation_id} version #{relation_v1.version} shouldn't be present in the history, even when logged in."
     end
 
+    def test_show
+      relation = create(:relation, :with_history, :version => 2)
+      create(:old_relation_tag, :old_relation => relation.old_relations[0], :k => "k1", :v => "v1")
+      create(:old_relation_tag, :old_relation => relation.old_relations[1], :k => "k2", :v => "v2")
+
+      get api_relation_version_path(relation, 1)
+
+      assert_response :success
+      assert_dom "osm:root", 1 do
+        assert_dom "> relation", 1 do
+          assert_dom "> @id", relation.id.to_s
+          assert_dom "> @version", "1"
+          assert_dom "> tag", 1 do
+            assert_dom "> @k", "k1"
+            assert_dom "> @v", "v1"
+          end
+        end
+      end
+
+      get api_relation_version_path(relation, 2)
+
+      assert_response :success
+      assert_dom "osm:root", 1 do
+        assert_dom "> relation", 1 do
+          assert_dom "> @id", relation.id.to_s
+          assert_dom "> @version", "2"
+          assert_dom "> tag", 1 do
+            assert_dom "> @k", "k2"
+            assert_dom "> @v", "v2"
+          end
+        end
+      end
+    end
+
+    ##
+    # test that redacted relations aren't visible, regardless of
+    # authorisation except as moderator...
+    def test_show_redacted
+      relation = create(:relation, :with_history, :version => 2)
+      relation_v1 = relation.old_relations.find_by(:version => 1)
+      relation_v1.redact!(create(:redaction))
+
+      get api_relation_version_path(relation_v1.relation_id, relation_v1.version)
+      assert_response :forbidden, "Redacted relation shouldn't be visible via the version API."
+
+      # not even to a logged-in user
+      auth_header = bearer_authorization_header
+      get api_relation_version_path(relation_v1.relation_id, relation_v1.version), :headers => auth_header
+      assert_response :forbidden, "Redacted relation shouldn't be visible via the version API, even when logged in."
+    end
+
     ##
     # test the redaction of an old version of a relation, while not being
     # authorised.
@@ -134,23 +185,6 @@ module Api
       assert_response :success, "should be OK to redact old version as moderator with write_redactions scope."
     end
 
-    ##
-    # test that redacted relations aren't visible, regardless of
-    # authorisation except as moderator...
-    def test_version_redacted
-      relation = create(:relation, :with_history, :version => 2)
-      relation_v1 = relation.old_relations.find_by(:version => 1)
-      relation_v1.redact!(create(:redaction))
-
-      get api_old_relation_path(relation_v1.relation_id, relation_v1.version)
-      assert_response :forbidden, "Redacted relation shouldn't be visible via the version API."
-
-      # not even to a logged-in user
-      auth_header = bearer_authorization_header
-      get api_old_relation_path(relation_v1.relation_id, relation_v1.version), :headers => auth_header
-      assert_response :forbidden, "Redacted relation shouldn't be visible via the version API, even when logged in."
-    end
-
     ##
     # test the redaction of an old version of a relation, while being
     # authorised as a moderator.
@@ -165,9 +199,9 @@ module Api
 
       # check moderator can still see the redacted data, when passing
       # the appropriate flag
-      get api_old_relation_path(relation_v3.relation_id, relation_v3.version), :headers => auth_header
+      get api_relation_version_path(relation_v3.relation_id, relation_v3.version), :headers => auth_header
       assert_response :forbidden, "After redaction, relation should be gone for moderator, when flag not passed."
-      get api_old_relation_path(relation_v3.relation_id, relation_v3.version, :show_redactions => "true"), :headers => auth_header
+      get api_relation_version_path(relation_v3.relation_id, relation_v3.version, :show_redactions => "true"), :headers => auth_header
       assert_response :success, "After redaction, relation should not be gone for moderator, when flag passed."
 
       # and when accessed via history
@@ -196,7 +230,7 @@ module Api
       auth_header = bearer_authorization_header
 
       # check can't see the redacted data
-      get api_old_relation_path(relation_v3.relation_id, relation_v3.version), :headers => auth_header
+      get api_relation_version_path(relation_v3.relation_id, relation_v3.version), :headers => auth_header
       assert_response :forbidden, "Redacted relation shouldn't be visible via the version API."
 
       # and when accessed via history
@@ -247,7 +281,7 @@ module Api
 
       # check moderator can still see the redacted data, without passing
       # the appropriate flag
-      get api_old_relation_path(relation_v1.relation_id, relation_v1.version), :headers => auth_header
+      get api_relation_version_path(relation_v1.relation_id, relation_v1.version), :headers => auth_header
       assert_response :success, "After unredaction, relation should not be gone for moderator."
 
       # and when accessed via history
@@ -259,7 +293,7 @@ module Api
       auth_header = bearer_authorization_header
 
       # check normal user can now see the redacted data
-      get api_old_relation_path(relation_v1.relation_id, relation_v1.version), :headers => auth_header
+      get api_relation_version_path(relation_v1.relation_id, relation_v1.version), :headers => auth_header
       assert_response :success, "After redaction, node should not be gone for normal user."
 
       # and when accessed via history
@@ -321,7 +355,7 @@ module Api
     end
 
     def do_redact_relation(relation, redaction, headers = {})
-      get api_old_relation_path(relation.relation_id, relation.version)
+      get api_relation_version_path(relation.relation_id, relation.version)
       assert_response :success, "should be able to get version #{relation.version} of relation #{relation.relation_id}."
 
       # now redact it
index 5b8b6be0783ae8bb07b52f2eae8627a6b0857f9f..6cfa1d3d8b960e6bc9d362644a8b5cbde59eeccf 100644 (file)
@@ -15,15 +15,15 @@ module Api
       )
       assert_routing(
         { :path => "/api/0.6/way/1/2", :method => :get },
-        { :controller => "api/old_ways", :action => "show", :id => "1", :version => "2" }
+        { :controller => "api/old_ways", :action => "show", :way_id => "1", :version => "2" }
       )
       assert_routing(
         { :path => "/api/0.6/way/1/2.json", :method => :get },
-        { :controller => "api/old_ways", :action => "show", :id => "1", :version => "2", :format => "json" }
+        { :controller => "api/old_ways", :action => "show", :way_id => "1", :version => "2", :format => "json" }
       )
       assert_routing(
         { :path => "/api/0.6/way/1/2/redact", :method => :post },
-        { :controller => "api/old_ways", :action => "redact", :id => "1", :version => "2" }
+        { :controller => "api/old_ways", :action => "redact", :way_id => "1", :version => "2" }
       )
     end
 
@@ -82,7 +82,7 @@ module Api
 
     ##
     # check that we can retrieve versions of a way
-    def test_version
+    def test_show
       way = create(:way, :with_history)
       used_way = create(:way, :with_history)
       create(:relation_member, :member => used_way)
@@ -100,6 +100,23 @@ module Api
       check_current_version(way_with_versions.id)
     end
 
+    ##
+    # test that redacted ways aren't visible, regardless of
+    # authorisation except as moderator...
+    def test_show_redacted
+      way = create(:way, :with_history, :version => 2)
+      way_v1 = way.old_ways.find_by(:version => 1)
+      way_v1.redact!(create(:redaction))
+
+      get api_way_version_path(way_v1.way_id, way_v1.version)
+      assert_response :forbidden, "Redacted way shouldn't be visible via the version API."
+
+      # not even to a logged-in user
+      auth_header = bearer_authorization_header
+      get api_way_version_path(way_v1.way_id, way_v1.version), :headers => auth_header
+      assert_response :forbidden, "Redacted way shouldn't be visible via the version API, even when logged in."
+    end
+
     ##
     # check that returned history is the same as getting all
     # versions of a way from the api.
@@ -173,23 +190,6 @@ module Api
       assert_response :success, "should be OK to redact old version as moderator with write_redactions scope."
     end
 
-    ##
-    # test that redacted ways aren't visible, regardless of
-    # authorisation except as moderator...
-    def test_version_redacted
-      way = create(:way, :with_history, :version => 2)
-      way_v1 = way.old_ways.find_by(:version => 1)
-      way_v1.redact!(create(:redaction))
-
-      get api_old_way_path(way_v1.way_id, way_v1.version)
-      assert_response :forbidden, "Redacted way shouldn't be visible via the version API."
-
-      # not even to a logged-in user
-      auth_header = bearer_authorization_header
-      get api_old_way_path(way_v1.way_id, way_v1.version), :headers => auth_header
-      assert_response :forbidden, "Redacted way shouldn't be visible via the version API, even when logged in."
-    end
-
     ##
     # test the redaction of an old version of a way, while being
     # authorised as a moderator.
@@ -203,9 +203,9 @@ module Api
 
       # check moderator can still see the redacted data, when passing
       # the appropriate flag
-      get api_old_way_path(way_v3.way_id, way_v3.version), :headers => auth_header
+      get api_way_version_path(way_v3.way_id, way_v3.version), :headers => auth_header
       assert_response :forbidden, "After redaction, node should be gone for moderator, when flag not passed."
-      get api_old_way_path(way_v3.way_id, way_v3.version, :show_redactions => "true"), :headers => auth_header
+      get api_way_version_path(way_v3.way_id, way_v3.version, :show_redactions => "true"), :headers => auth_header
       assert_response :success, "After redaction, node should not be gone for moderator, when flag passed."
 
       # and when accessed via history
@@ -233,7 +233,7 @@ module Api
       auth_header = bearer_authorization_header
 
       # check can't see the redacted data
-      get api_old_way_path(way_v3.way_id, way_v3.version), :headers => auth_header
+      get api_way_version_path(way_v3.way_id, way_v3.version), :headers => auth_header
       assert_response :forbidden, "Redacted node shouldn't be visible via the version API."
 
       # and when accessed via history
@@ -285,7 +285,7 @@ module Api
 
       # check moderator can still see the unredacted data, without passing
       # the appropriate flag
-      get api_old_way_path(way_v1.way_id, way_v1.version), :headers => auth_header
+      get api_way_version_path(way_v1.way_id, way_v1.version), :headers => auth_header
       assert_response :success, "After unredaction, node should not be gone for moderator."
 
       # and when accessed via history
@@ -297,7 +297,7 @@ module Api
       auth_header = bearer_authorization_header
 
       # check normal user can now see the unredacted data
-      get api_old_way_path(way_v1.way_id, way_v1.version), :headers => auth_header
+      get api_way_version_path(way_v1.way_id, way_v1.version), :headers => auth_header
       assert_response :success, "After redaction, node should not be gone for moderator, when flag passed."
 
       # and when accessed via history
@@ -322,7 +322,7 @@ module Api
       assert_not_nil current_way, "getting way #{way_id} returned nil"
 
       # get the "old" version of the way from the version method
-      get api_old_way_path(way_id, current_way.version)
+      get api_way_version_path(way_id, current_way.version)
       assert_response :success, "can't get old way #{way_id}, v#{current_way.version}"
       old_way = Way.from_xml(@response.body)
 
@@ -343,7 +343,7 @@ module Api
         history_way = Way.from_xml_node(way_doc)
         assert_not_nil history_way, "parsing way #{way_id} version failed"
 
-        get api_old_way_path(way_id, history_way.version)
+        get api_way_version_path(way_id, history_way.version)
         assert_response :success, "couldn't get way #{way_id}, v#{history_way.version}"
         version_way = Way.from_xml(@response.body)
         assert_not_nil version_way, "failed to parse #{way_id}, v#{history_way.version}"
@@ -359,7 +359,7 @@ module Api
     end
 
     def do_redact_way(way, redaction, headers = {})
-      get api_old_way_path(way.way_id, way.version)
+      get api_way_version_path(way.way_id, way.version)
       assert_response :success, "should be able to get version #{way.version} of way #{way.way_id}."
 
       # now redact it
index 5e480b69c0b1d02584554a2ba43b9578f444f8c2..9e2972495756de8b987d642b5f90ab4d4ee7667a 100644 (file)
@@ -782,7 +782,7 @@ module Api
 
       # check the ordering in the history tables:
       with_controller(OldRelationsController.new) do
-        get api_old_relation_path(relation_id, 2)
+        get api_relation_version_path(relation_id, 2)
         assert_response :success, "can't read back version 2 of the relation #{relation_id}"
         check_ordering(doc, @response.body)
       end
@@ -862,7 +862,7 @@ module Api
 
       # check the ordering in the history tables:
       with_controller(OldRelationsController.new) do
-        get api_old_relation_path(relation_id, 1)
+        get api_relation_version_path(relation_id, 1)
         assert_response :success, "can't read back version 1 of the relation: #{@response.body}"
         check_ordering(doc, @response.body)
       end
@@ -1084,7 +1084,7 @@ module Api
         get api_relation_path(id)
       else
         with_controller(OldRelationsController.new) do
-          get api_old_relation_path(id, ver)
+          get api_relation_version_path(id, ver)
         end
       end
       assert_response :success
index 8e3a14ab6c8717a5860dbb7a1d8ed2284ce9bad2..aba69b03aa4135985daa3683f1bdb3ea6ecc9e8f 100644 (file)
@@ -114,7 +114,7 @@ class OldNodesControllerTest < ActionDispatch::IntegrationTest
     assert_select "h4", /^Version/ do
       assert_select "a[href='#{old_node_path node, 1}']", :count => 0
     end
-    assert_select ".secondary-actions a[href='#{api_old_node_path node, 1}']", :count => 1
+    assert_select ".secondary-actions a[href='#{api_node_version_path node, 1}']", :count => 1
     assert_select ".secondary-actions a[href='#{node_path node}']", :count => 1
     assert_select ".secondary-actions a[href='#{old_node_path node, 1, :params => { :show_redactions => true }}']", :count => 0
     assert_select ".secondary-actions a[href='#{node_history_path node}']", :count => 1
@@ -129,7 +129,7 @@ class OldNodesControllerTest < ActionDispatch::IntegrationTest
     assert_select "h4", /^Version/ do
       assert_select "a[href='#{old_node_path node, 1}']", :count => 0
     end
-    assert_select ".secondary-actions a[href='#{api_old_node_path node, 1}']", :count => 1
+    assert_select ".secondary-actions a[href='#{api_node_version_path node, 1}']", :count => 1
     assert_select ".secondary-actions a[href='#{node_path node}']", :count => 1
     assert_select ".secondary-actions a[href='#{node_history_path node}']", :count => 1
     assert_select ".secondary-actions a[href='#{old_node_path node, 2}']", :count => 1
@@ -141,7 +141,7 @@ class OldNodesControllerTest < ActionDispatch::IntegrationTest
     assert_select "h4", /^Version/ do
       assert_select "a[href='#{old_node_path node, 2}']", :count => 0
     end
-    assert_select ".secondary-actions a[href='#{api_old_node_path node, 2}']", :count => 1
+    assert_select ".secondary-actions a[href='#{api_node_version_path node, 2}']", :count => 1
     assert_select ".secondary-actions a[href='#{node_path node}']", :count => 1
     assert_select ".secondary-actions a[href='#{node_history_path node}']", :count => 1
     assert_select ".secondary-actions a[href='#{old_node_path node, 1}']", :count => 1
@@ -157,7 +157,7 @@ class OldNodesControllerTest < ActionDispatch::IntegrationTest
     assert_select ".secondary-actions a[href='#{node_path node}']", :count => 1
     assert_select ".secondary-actions a[href='#{old_node_path node, 1, :params => { :show_redactions => true }}']", :count => 0
     assert_select ".secondary-actions a[href='#{old_node_path node, 1}']", :count => 0
-    assert_select ".secondary-actions a[href='#{api_old_node_path node, 1}']", :count => 0
+    assert_select ".secondary-actions a[href='#{api_node_version_path node, 1}']", :count => 0
   end
 
   test "show unrevealed redacted versions to regular users" do
@@ -171,7 +171,7 @@ class OldNodesControllerTest < ActionDispatch::IntegrationTest
     assert_select ".secondary-actions a[href='#{node_path node}']", :count => 1
     assert_select ".secondary-actions a[href='#{old_node_path node, 1, :params => { :show_redactions => true }}']", :count => 0
     assert_select ".secondary-actions a[href='#{old_node_path node, 1}']", :count => 0
-    assert_select ".secondary-actions a[href='#{api_old_node_path node, 1}']", :count => 0
+    assert_select ".secondary-actions a[href='#{api_node_version_path node, 1}']", :count => 0
   end
 
   test "show unrevealed redacted versions to moderators" do
@@ -185,7 +185,7 @@ class OldNodesControllerTest < ActionDispatch::IntegrationTest
     assert_select ".secondary-actions a[href='#{node_path node}']", :count => 1
     assert_select ".secondary-actions a[href='#{old_node_path node, 1, :params => { :show_redactions => true }}']", :count => 1
     assert_select ".secondary-actions a[href='#{old_node_path node, 1}']", :count => 0
-    assert_select ".secondary-actions a[href='#{api_old_node_path node, 1}']", :count => 0
+    assert_select ".secondary-actions a[href='#{api_node_version_path node, 1}']", :count => 0
   end
 
   test "don't reveal redacted versions to anonymous users" do
index 3ede1842b5d35137602c92dde30a3ddf1e83f9b2..cd6737dca32070b651f30dba7a2f9242dabe8d27 100644 (file)
@@ -64,7 +64,7 @@ class OldRelationsControllerTest < ActionDispatch::IntegrationTest
     assert_select "h4", /^Version/ do
       assert_select "a[href='#{old_relation_path relation, 1}']", :count => 0
     end
-    assert_select ".secondary-actions a[href='#{api_old_relation_path relation, 1}']", :count => 1
+    assert_select ".secondary-actions a[href='#{api_relation_version_path relation, 1}']", :count => 1
     assert_select ".secondary-actions a[href='#{relation_path relation}']", :count => 1
     assert_select ".secondary-actions a[href='#{old_relation_path relation, 1, :params => { :show_redactions => true }}']", :count => 0
     assert_select ".secondary-actions a[href='#{relation_history_path relation}']", :count => 1
@@ -79,7 +79,7 @@ class OldRelationsControllerTest < ActionDispatch::IntegrationTest
     assert_select "h4", /^Version/ do
       assert_select "a[href='#{old_relation_path relation, 1}']", :count => 0
     end
-    assert_select ".secondary-actions a[href='#{api_old_relation_path relation, 1}']", :count => 1
+    assert_select ".secondary-actions a[href='#{api_relation_version_path relation, 1}']", :count => 1
     assert_select ".secondary-actions a[href='#{relation_path relation}']", :count => 1
     assert_select ".secondary-actions a[href='#{relation_history_path relation}']", :count => 1
     assert_select ".secondary-actions a[href='#{old_relation_path relation, 2}']", :count => 1
@@ -91,7 +91,7 @@ class OldRelationsControllerTest < ActionDispatch::IntegrationTest
     assert_select "h4", /^Version/ do
       assert_select "a[href='#{old_relation_path relation, 2}']", :count => 0
     end
-    assert_select ".secondary-actions a[href='#{api_old_relation_path relation, 2}']", :count => 1
+    assert_select ".secondary-actions a[href='#{api_relation_version_path relation, 2}']", :count => 1
     assert_select ".secondary-actions a[href='#{relation_path relation}']", :count => 1
     assert_select ".secondary-actions a[href='#{relation_history_path relation}']", :count => 1
     assert_select ".secondary-actions a[href='#{old_relation_path relation, 1}']", :count => 1
@@ -116,7 +116,7 @@ class OldRelationsControllerTest < ActionDispatch::IntegrationTest
     assert_select ".secondary-actions a[href='#{relation_path relation}']", :count => 1
     assert_select ".secondary-actions a[href='#{old_relation_path relation, 1, :params => { :show_redactions => true }}']", :count => 0
     assert_select ".secondary-actions a[href='#{old_relation_path relation, 1}']", :count => 0
-    assert_select ".secondary-actions a[href='#{api_old_relation_path relation, 1}']", :count => 0
+    assert_select ".secondary-actions a[href='#{api_relation_version_path relation, 1}']", :count => 0
   end
 
   test "show unrevealed redacted versions to regular users" do
@@ -130,7 +130,7 @@ class OldRelationsControllerTest < ActionDispatch::IntegrationTest
     assert_select ".secondary-actions a[href='#{relation_path relation}']", :count => 1
     assert_select ".secondary-actions a[href='#{old_relation_path relation, 1, :params => { :show_redactions => true }}']", :count => 0
     assert_select ".secondary-actions a[href='#{old_relation_path relation, 1}']", :count => 0
-    assert_select ".secondary-actions a[href='#{api_old_relation_path relation, 1}']", :count => 0
+    assert_select ".secondary-actions a[href='#{api_relation_version_path relation, 1}']", :count => 0
   end
 
   test "show unrevealed redacted versions to moderators" do
@@ -144,7 +144,7 @@ class OldRelationsControllerTest < ActionDispatch::IntegrationTest
     assert_select ".secondary-actions a[href='#{relation_path relation}']", :count => 1
     assert_select ".secondary-actions a[href='#{old_relation_path relation, 1, :params => { :show_redactions => true }}']", :count => 1
     assert_select ".secondary-actions a[href='#{old_relation_path relation, 1}']", :count => 0
-    assert_select ".secondary-actions a[href='#{api_old_relation_path relation, 1}']", :count => 0
+    assert_select ".secondary-actions a[href='#{api_relation_version_path relation, 1}']", :count => 0
   end
 
   test "don't reveal redacted versions to anonymous users" do
index c7b383202bb45081f2396b4a916e93108f9ab606..3ac6eaf2f0fd87c5466578627f8487a979ae6386 100644 (file)
@@ -64,7 +64,7 @@ class OldWaysControllerTest < ActionDispatch::IntegrationTest
     assert_select "h4", /^Version/ do
       assert_select "a[href='#{old_way_path way, 1}']", :count => 0
     end
-    assert_select ".secondary-actions a[href='#{api_old_way_path way, 1}']", :count => 1
+    assert_select ".secondary-actions a[href='#{api_way_version_path way, 1}']", :count => 1
     assert_select ".secondary-actions a[href='#{way_path way}']", :count => 1
     assert_select ".secondary-actions a[href='#{old_way_path way, 1, :params => { :show_redactions => true }}']", :count => 0
     assert_select ".secondary-actions a[href='#{way_history_path way}']", :count => 1
@@ -79,7 +79,7 @@ class OldWaysControllerTest < ActionDispatch::IntegrationTest
     assert_select "h4", /^Version/ do
       assert_select "a[href='#{old_way_path way, 1}']", :count => 0
     end
-    assert_select ".secondary-actions a[href='#{api_old_way_path way, 1}']", :count => 1
+    assert_select ".secondary-actions a[href='#{api_way_version_path way, 1}']", :count => 1
     assert_select ".secondary-actions a[href='#{way_path way}']", :count => 1
     assert_select ".secondary-actions a[href='#{way_history_path way}']", :count => 1
     assert_select ".secondary-actions a[href='#{old_way_path way, 2}']", :count => 1
@@ -91,7 +91,7 @@ class OldWaysControllerTest < ActionDispatch::IntegrationTest
     assert_select "h4", /^Version/ do
       assert_select "a[href='#{old_way_path way, 2}']", :count => 0
     end
-    assert_select ".secondary-actions a[href='#{api_old_way_path way, 2}']", :count => 1
+    assert_select ".secondary-actions a[href='#{api_way_version_path way, 2}']", :count => 1
     assert_select ".secondary-actions a[href='#{way_path way}']", :count => 1
     assert_select ".secondary-actions a[href='#{way_history_path way}']", :count => 1
     assert_select ".secondary-actions a[href='#{old_way_path way, 1}']", :count => 1
@@ -121,7 +121,7 @@ class OldWaysControllerTest < ActionDispatch::IntegrationTest
     assert_select ".secondary-actions a[href='#{way_path way}']", :count => 1
     assert_select ".secondary-actions a[href='#{old_way_path way, 1, :params => { :show_redactions => true }}']", :count => 0
     assert_select ".secondary-actions a[href='#{old_way_path way, 1}']", :count => 0
-    assert_select ".secondary-actions a[href='#{api_old_way_path way, 1}']", :count => 0
+    assert_select ".secondary-actions a[href='#{api_way_version_path way, 1}']", :count => 0
   end
 
   test "show unrevealed redacted versions to regular users" do
@@ -135,7 +135,7 @@ class OldWaysControllerTest < ActionDispatch::IntegrationTest
     assert_select ".secondary-actions a[href='#{way_path way}']", :count => 1
     assert_select ".secondary-actions a[href='#{old_way_path way, 1, :params => { :show_redactions => true }}']", :count => 0
     assert_select ".secondary-actions a[href='#{old_way_path way, 1}']", :count => 0
-    assert_select ".secondary-actions a[href='#{api_old_way_path way, 1}']", :count => 0
+    assert_select ".secondary-actions a[href='#{api_way_version_path way, 1}']", :count => 0
   end
 
   test "show unrevealed redacted versions to moderators" do
@@ -149,7 +149,7 @@ class OldWaysControllerTest < ActionDispatch::IntegrationTest
     assert_select ".secondary-actions a[href='#{way_path way}']", :count => 1
     assert_select ".secondary-actions a[href='#{old_way_path way, 1, :params => { :show_redactions => true }}']", :count => 1
     assert_select ".secondary-actions a[href='#{old_way_path way, 1}']", :count => 0
-    assert_select ".secondary-actions a[href='#{api_old_way_path way, 1}']", :count => 0
+    assert_select ".secondary-actions a[href='#{api_way_version_path way, 1}']", :count => 0
   end
 
   test "don't reveal redacted versions to anonymous users" do