]> git.openstreetmap.org Git - rails.git/commitdiff
Don't link to xml download from redacted element versions
authorAnton Khorev <tony29@yandex.ru>
Wed, 17 Jan 2024 16:57:49 +0000 (19:57 +0300)
committerAnton Khorev <tony29@yandex.ru>
Tue, 23 Jan 2024 19:08:39 +0000 (22:08 +0300)
app/views/old_nodes/show.html.erb
app/views/old_relations/show.html.erb
app/views/old_ways/show.html.erb
test/controllers/old_nodes_controller_test.rb
test/controllers/old_relations_controller_test.rb
test/controllers/old_ways_controller_test.rb

index 6a16c789c3feafb347723aa73ed438783cc53e08..b5758b44a77b0c44b90c4604331391fae46f33c6 100644 (file)
@@ -4,6 +4,8 @@
 
 <%= render :partial => "browse/node", :object => @feature %>
 
-<div class='secondary-actions'>
-  <%= link_to t("browse.download_xml"), node_version_path(*@feature.id) %>
-</div>
+<% unless @feature.redacted? %>
+  <div class='secondary-actions'>
+    <%= link_to t("browse.download_xml"), node_version_path(*@feature.id) %>
+  </div>
+<% end %>
index 1a34e9adec62f8636e797883b2f3bea627f39432..cfa27c1adc6e31a9cf7fc3b201a1b0f0bc3cf1d3 100644 (file)
@@ -4,6 +4,8 @@
 
 <%= render :partial => "browse/relation", :object => @feature %>
 
-<div class='secondary-actions'>
-  <%= link_to t("browse.download_xml"), relation_version_path(*@feature.id) %>
-</div>
+<% unless @feature.redacted? %>
+  <div class='secondary-actions'>
+    <%= link_to t("browse.download_xml"), relation_version_path(*@feature.id) %>
+  </div>
+<% end %>
index c7826a51134055d7c70ed7e13495414f010b2476..6e66fa5153a94dbfe3c2f711e500af14b0a1224b 100644 (file)
@@ -4,6 +4,8 @@
 
 <%= render :partial => "browse/way", :object => @feature %>
 
-<div class='secondary-actions'>
-  <%= link_to t("browse.download_xml"), way_version_path(*@feature.id) %>
-</div>
+<% unless @feature.redacted? %>
+  <div class='secondary-actions'>
+    <%= link_to t("browse.download_xml"), way_version_path(*@feature.id) %>
+  </div>
+<% end %>
index 2e27983d037132e85c75be1286d7123057bcbaa4..dc1a5cce88d98a4b2f5cd60e8508ea8283e98955 100644 (file)
@@ -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
index 488852ed975ac403c2fa6372ecb31c0a08737690..87c4926efd4c4be623d2242021e44fe567c17126 100644 (file)
@@ -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
index f32fdde7756f6c12f092e74141111464ed1ded68..67c4fb0007f3bae1f870354eea45bb3ad5d62750 100644 (file)
@@ -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