]> git.openstreetmap.org Git - rails.git/commitdiff
Rewrite bbox only in place history atom links
authorAnton Khorev <tony29@yandex.ru>
Wed, 7 Sep 2022 19:13:57 +0000 (22:13 +0300)
committerAnton Khorev <tony29@yandex.ru>
Wed, 7 Sep 2022 19:13:57 +0000 (22:13 +0300)
app/assets/javascripts/index/history.js
test/system/history_test.rb [new file with mode: 0644]

index c20d342c5c3bafcdbfab633cd6160386de428fd2..d137b84565f1ad74755b8ed269c8d737d5c71dd3 100644 (file)
@@ -48,6 +48,9 @@ OSM.History = function (map) {
 
     if (window.location.pathname === "/history") {
       data.bbox = map.getBounds().wrap().toBBoxString();
 
     if (window.location.pathname === "/history") {
       data.bbox = map.getBounds().wrap().toBBoxString();
+      var feedLink = $("link[type=\"application/atom+xml\"]"),
+          feedHref = feedLink.attr("href").split("?")[0];
+      feedLink.attr("href", feedHref + "?bbox=" + data.bbox);
     }
 
     $.ajax({
     }
 
     $.ajax({
@@ -59,11 +62,6 @@ OSM.History = function (map) {
         updateMap();
       }
     });
         updateMap();
       }
     });
-
-    var feedLink = $("link[type=\"application/atom+xml\"]"),
-        feedHref = feedLink.attr("href").split("?")[0];
-
-    feedLink.attr("href", feedHref + "?bbox=" + data.bbox);
   }
 
   function loadMore(e) {
   }
 
   function loadMore(e) {
diff --git a/test/system/history_test.rb b/test/system/history_test.rb
new file mode 100644 (file)
index 0000000..45654b8
--- /dev/null
@@ -0,0 +1,16 @@
+require "application_system_test_case"
+
+class HistoryTest < ApplicationSystemTestCase
+  test "atom link on user's history is not modified" do
+    user = create(:user)
+    create(:changeset, :user => user, :num_changes => 1) do |changeset|
+      create(:changeset_tag, :changeset => changeset, :k => "comment", :v => "first-changeset-in-history")
+    end
+
+    visit "#{user_path(user)}/history"
+    changesets = find "div.changesets"
+    changesets.assert_text "first-changeset-in-history"
+
+    assert_css "link[type='application/atom+xml'][href$='#{user_path(user)}/history/feed']", :visible => false
+  end
+end