From 1fc2a70c1713172317acb14b76ef8ac45d994065 Mon Sep 17 00:00:00 2001 From: Anton Khorev Date: Wed, 7 Sep 2022 22:13:57 +0300 Subject: [PATCH] Rewrite bbox only in place history atom links --- app/assets/javascripts/index/history.js | 8 +++----- test/system/history_test.rb | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 5 deletions(-) create mode 100644 test/system/history_test.rb diff --git a/app/assets/javascripts/index/history.js b/app/assets/javascripts/index/history.js index c20d342c5..d137b8456 100644 --- a/app/assets/javascripts/index/history.js +++ b/app/assets/javascripts/index/history.js @@ -48,6 +48,9 @@ OSM.History = function (map) { 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({ @@ -59,11 +62,6 @@ OSM.History = function (map) { updateMap(); } }); - - var feedLink = $("link[type=\"application/atom+xml\"]"), - feedHref = feedLink.attr("href").split("?")[0]; - - feedLink.attr("href", feedHref + "?bbox=" + data.bbox); } function loadMore(e) { diff --git a/test/system/history_test.rb b/test/system/history_test.rb new file mode 100644 index 000000000..45654b88d --- /dev/null +++ b/test/system/history_test.rb @@ -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 -- 2.39.5