diff --git a/app/controllers/api/old_nodes_controller.rb b/app/controllers/api/old_nodes_controller.rb index eb6c1acf5f..b63761af9c 100644 --- a/app/controllers/api/old_nodes_controller.rb +++ b/app/controllers/api/old_nodes_controller.rb @@ -3,7 +3,7 @@ class OldNodesController < OldElementsController 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 diff --git a/app/controllers/api/old_relations_controller.rb b/app/controllers/api/old_relations_controller.rb index 6321b9adfb..c065c657d1 100644 --- a/app/controllers/api/old_relations_controller.rb +++ b/app/controllers/api/old_relations_controller.rb @@ -3,7 +3,7 @@ class OldRelationsController < OldElementsController 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 diff --git a/app/controllers/api/old_ways_controller.rb b/app/controllers/api/old_ways_controller.rb index 73226dee6e..654100767f 100644 --- a/app/controllers/api/old_ways_controller.rb +++ b/app/controllers/api/old_ways_controller.rb @@ -3,7 +3,7 @@ class OldWaysController < OldElementsController 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 diff --git a/app/views/old_elements/_actions.html.erb b/app/views/old_elements/_actions.html.erb index 36a16abb45..b4d28123ce 100644 --- a/app/views/old_elements/_actions.html.erb +++ b/app/views/old_elements/_actions.html.erb @@ -2,7 +2,7 @@ <%= link_to t("browse.view_details"), :controller => @type.pluralize, :action => :show %> <% if !@feature.redacted? %> · - <%= 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? %> · <% if !params[:show_redactions] %> diff --git a/config/routes.rb b/config/routes.rb index 0d9950d048..54bf037cf2 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -30,14 +30,11 @@ 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 @@ 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 @@ 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 @@ 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 diff --git a/test/controllers/api/old_nodes_controller_test.rb b/test/controllers/api/old_nodes_controller_test.rb index 2b1585be20..8cb3abb0fd 100644 --- a/test/controllers/api/old_nodes_controller_test.rb +++ b/test/controllers/api/old_nodes_controller_test.rb @@ -15,15 +15,15 @@ def test_routes ) 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 @@ def test_index_redacted # ## # 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 @@ def test_version # 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 @@ def test_version 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 @@ def test_redact_node_by_moderator_with_write_redactions_scope 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 @@ def test_redact_node_moderator # 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 @@ def test_redact_node_is_redacted 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 @@ def test_unredact_node_moderator # 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 @@ def test_unredact_node_moderator 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 @@ def do_redact_redactable_node(headers = {}) 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 @@ def check_current_version(node_id) 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 @@ def check_current_version(node_id) 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) diff --git a/test/controllers/api/old_relations_controller_test.rb b/test/controllers/api/old_relations_controller_test.rb index 506c6a1ed5..3eec3c87fc 100644 --- a/test/controllers/api/old_relations_controller_test.rb +++ b/test/controllers/api/old_relations_controller_test.rb @@ -15,15 +15,15 @@ def test_routes ) 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 @@ def test_index_redacted "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 @@ def test_redact_relation_by_moderator_with_write_redactions_scope 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 @@ def test_redact_relation_moderator # 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 @@ def test_redact_relation_is_redacted 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 @@ def test_unredact_relation_moderator # 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 @@ def test_unredact_relation_moderator 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 @@ def do_redact_redactable_relation(headers = {}) 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 diff --git a/test/controllers/api/old_ways_controller_test.rb b/test/controllers/api/old_ways_controller_test.rb index 5b8b6be078..6cfa1d3d8b 100644 --- a/test/controllers/api/old_ways_controller_test.rb +++ b/test/controllers/api/old_ways_controller_test.rb @@ -15,15 +15,15 @@ def test_routes ) 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 @@ def test_index_redacted ## # 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 @@ def test_version 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 @@ def test_redact_way_by_moderator_with_write_redactions_scope 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 @@ def test_redact_way_moderator # 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 @@ def test_redact_way_is_redacted 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 @@ def test_unredact_way_moderator # 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 @@ def test_unredact_way_moderator 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 @@ def check_current_version(way_id) 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 @@ def check_history_equals_versions(way_id) 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 @@ def do_redact_redactable_way(headers = {}) 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 diff --git a/test/controllers/api/relations_controller_test.rb b/test/controllers/api/relations_controller_test.rb index 5e480b69c0..9e29724957 100644 --- a/test/controllers/api/relations_controller_test.rb +++ b/test/controllers/api/relations_controller_test.rb @@ -782,7 +782,7 @@ def test_relation_member_ordering # 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 @@ def test_history_ordering # 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 @@ def with_relation(id, ver = nil) 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 diff --git a/test/controllers/old_nodes_controller_test.rb b/test/controllers/old_nodes_controller_test.rb index 8e3a14ab6c..aba69b03aa 100644 --- a/test/controllers/old_nodes_controller_test.rb +++ b/test/controllers/old_nodes_controller_test.rb @@ -114,7 +114,7 @@ def test_visible_with_one_version 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 @@ def test_visible_with_two_versions 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 @@ def test_visible_with_two_versions 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 @@ def test_visible_with_two_versions 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 @@ def test_visible_with_two_versions 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 @@ def test_visible_with_two_versions 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 diff --git a/test/controllers/old_relations_controller_test.rb b/test/controllers/old_relations_controller_test.rb index 3ede1842b5..cd6737dca3 100644 --- a/test/controllers/old_relations_controller_test.rb +++ b/test/controllers/old_relations_controller_test.rb @@ -64,7 +64,7 @@ def test_visible_with_one_version 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 @@ def test_visible_with_two_versions 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 @@ def test_visible_with_two_versions 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 @@ def test_visible_with_members 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 @@ def test_visible_with_members 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 @@ def test_visible_with_members 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 diff --git a/test/controllers/old_ways_controller_test.rb b/test/controllers/old_ways_controller_test.rb index c7b383202b..3ac6eaf2f0 100644 --- a/test/controllers/old_ways_controller_test.rb +++ b/test/controllers/old_ways_controller_test.rb @@ -64,7 +64,7 @@ def test_visible_with_one_version 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 @@ def test_visible_with_two_versions 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 @@ def test_visible_with_two_versions 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 @@ def test_visible_with_shared_nodes 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 @@ def test_visible_with_shared_nodes 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 @@ def test_visible_with_shared_nodes 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