From: Anton Khorev Date: Wed, 17 Jan 2024 16:57:49 +0000 (+0300) Subject: Don't link to xml download from redacted element versions X-Git-Tag: live~1098^2~7 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/7c55a5cb3b07f40ab1897a7d746de27317255c42 Don't link to xml download from redacted element versions --- diff --git a/app/views/old_nodes/show.html.erb b/app/views/old_nodes/show.html.erb index 6a16c789c..b5758b44a 100644 --- a/app/views/old_nodes/show.html.erb +++ b/app/views/old_nodes/show.html.erb @@ -4,6 +4,8 @@ <%= render :partial => "browse/node", :object => @feature %> -
- <%= link_to t("browse.download_xml"), node_version_path(*@feature.id) %> -
+<% unless @feature.redacted? %> +
+ <%= link_to t("browse.download_xml"), node_version_path(*@feature.id) %> +
+<% end %> diff --git a/app/views/old_relations/show.html.erb b/app/views/old_relations/show.html.erb index 1a34e9ade..cfa27c1ad 100644 --- a/app/views/old_relations/show.html.erb +++ b/app/views/old_relations/show.html.erb @@ -4,6 +4,8 @@ <%= render :partial => "browse/relation", :object => @feature %> -
- <%= link_to t("browse.download_xml"), relation_version_path(*@feature.id) %> -
+<% unless @feature.redacted? %> +
+ <%= link_to t("browse.download_xml"), relation_version_path(*@feature.id) %> +
+<% end %> diff --git a/app/views/old_ways/show.html.erb b/app/views/old_ways/show.html.erb index c7826a511..6e66fa515 100644 --- a/app/views/old_ways/show.html.erb +++ b/app/views/old_ways/show.html.erb @@ -4,6 +4,8 @@ <%= render :partial => "browse/way", :object => @feature %> -
- <%= link_to t("browse.download_xml"), way_version_path(*@feature.id) %> -
+<% unless @feature.redacted? %> +
+ <%= link_to t("browse.download_xml"), way_version_path(*@feature.id) %> +
+<% end %> diff --git a/test/controllers/old_nodes_controller_test.rb b/test/controllers/old_nodes_controller_test.rb index 2e27983d0..dc1a5cce8 100644 --- a/test/controllers/old_nodes_controller_test.rb +++ b/test/controllers/old_nodes_controller_test.rb @@ -20,6 +20,18 @@ class OldNodesControllerTest < ActionDispatch::IntegrationTest assert_select "a[href='#{node_version_path node, 1}']", :count => 1 end + def test_redacted + node = create(:node, :with_history, :deleted, :version => 2) + node_v1 = node.old_nodes.find_by(:version => 1) + node_v1.redact!(create(:redaction)) + get old_node_path(node, 1) + assert_response :success + assert_template "old_nodes/show" + assert_template :layout => "map" + assert_select "a[href='#{old_node_path node, 1}']", :count => 0 + assert_select "a[href='#{node_version_path node, 1}']", :count => 0 + end + def test_not_found get old_node_path(0, 0) assert_response :not_found diff --git a/test/controllers/old_relations_controller_test.rb b/test/controllers/old_relations_controller_test.rb index 488852ed9..87c4926ef 100644 --- a/test/controllers/old_relations_controller_test.rb +++ b/test/controllers/old_relations_controller_test.rb @@ -29,6 +29,18 @@ class OldRelationsControllerTest < ActionDispatch::IntegrationTest assert_template :layout => "map" end + def test_redacted + relation = create(:relation, :with_history, :deleted, :version => 2) + relation_v1 = relation.old_relations.find_by(:version => 1) + relation_v1.redact!(create(:redaction)) + get old_relation_path(relation, 1) + assert_response :success + assert_template "old_relations/show" + assert_template :layout => "map" + assert_select "a[href='#{old_relation_path relation, 1}']", :count => 0 + assert_select "a[href='#{relation_version_path relation, 1}']", :count => 0 + end + def test_not_found get old_relation_path(0, 0) assert_response :not_found diff --git a/test/controllers/old_ways_controller_test.rb b/test/controllers/old_ways_controller_test.rb index f32fdde77..67c4fb000 100644 --- a/test/controllers/old_ways_controller_test.rb +++ b/test/controllers/old_ways_controller_test.rb @@ -34,6 +34,18 @@ class OldWaysControllerTest < ActionDispatch::IntegrationTest assert_template :layout => "map" end + def test_redacted + way = create(:way, :with_history, :deleted, :version => 2) + way_v1 = way.old_ways.find_by(:version => 1) + way_v1.redact!(create(:redaction)) + get old_way_path(way, 1) + assert_response :success + assert_template "old_ways/show" + assert_template :layout => "map" + assert_select "a[href='#{old_way_path way, 1}']", :count => 0 + assert_select "a[href='#{way_version_path way, 1}']", :count => 0 + end + def test_not_found get old_way_path(0, 0) assert_response :not_found