]> git.openstreetmap.org Git - rails.git/commitdiff
Link to previous/next versions from relation version pages
authorAnton Khorev <tony29@yandex.ru>
Wed, 17 Jan 2024 18:25:07 +0000 (21:25 +0300)
committerAnton Khorev <tony29@yandex.ru>
Tue, 23 Jan 2024 19:08:39 +0000 (22:08 +0300)
app/views/old_relations/show.html.erb
test/controllers/old_relations_controller_test.rb

index cfa27c1adc6e31a9cf7fc3b201a1b0f0bc3cf1d3..dd52b383370dbcb14cfd0748dc73cbae37e54947 100644 (file)
@@ -9,3 +9,15 @@
     <%= link_to t("browse.download_xml"), relation_version_path(*@feature.id) %>
   </div>
 <% end %>
+
+<div class='secondary-actions'>
+  <% if @feature.version > 1 %>
+    <%= link_to "<< #{t('browse.version')} ##{@feature.version - 1}", old_relation_path(@feature.relation_id, @feature.version - 1) %>
+    &middot;
+  <% end %>
+  <%= link_to t("browse.view_history"), relation_history_path(@feature.relation_id) %>
+  <% if @feature.version < @feature.current_relation.version %>
+    &middot;
+    <%= link_to "#{t('browse.version')} ##{@feature.version + 1} >>", old_relation_path(@feature.relation_id, @feature.version + 1) %>
+  <% end %>
+</div>
index 87c4926efd4c4be623d2242021e44fe567c17126..5b7a67bf0caee16b2bb71423861f49ea4e10c649 100644 (file)
@@ -8,7 +8,7 @@ class OldRelationsControllerTest < ActionDispatch::IntegrationTest
     )
   end
 
-  def test_visible
+  def test_visible_with_one_version
     relation = create(:relation, :with_history)
     get old_relation_path(relation, 1)
     assert_response :success
@@ -17,7 +17,33 @@ class OldRelationsControllerTest < ActionDispatch::IntegrationTest
     assert_select "h4", /^Version/ do
       assert_select "a[href='#{old_relation_path relation, 1}']", :count => 0
     end
-    assert_select "a[href='#{relation_version_path relation, 1}']", :count => 1
+    assert_select ".secondary-actions a[href='#{relation_version_path relation, 1}']", :count => 1
+    assert_select ".secondary-actions a[href='#{relation_history_path relation}']", :count => 1
+  end
+
+  def test_visible_with_two_versions
+    relation = create(:relation, :with_history, :version => 2)
+    get old_relation_path(relation, 1)
+    assert_response :success
+    assert_template "old_relations/show"
+    assert_template :layout => "map"
+    assert_select "h4", /^Version/ do
+      assert_select "a[href='#{old_relation_path relation, 1}']", :count => 0
+    end
+    assert_select ".secondary-actions a[href='#{relation_version_path relation, 1}']", :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
+
+    get old_relation_path(relation, 2)
+    assert_response :success
+    assert_template "old_relations/show"
+    assert_template :layout => "map"
+    assert_select "h4", /^Version/ do
+      assert_select "a[href='#{old_relation_path relation, 2}']", :count => 0
+    end
+    assert_select ".secondary-actions a[href='#{relation_version_path relation, 2}']", :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
   end
 
   def test_visible_with_members
@@ -37,8 +63,8 @@ class OldRelationsControllerTest < ActionDispatch::IntegrationTest
     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
+    assert_select ".secondary-actions a[href='#{old_relation_path relation, 1}']", :count => 0
+    assert_select ".secondary-actions a[href='#{relation_version_path relation, 1}']", :count => 0
   end
 
   def test_not_found