]> git.openstreetmap.org Git - rails.git/commitdiff
Fix URL generation for atom feed on history page
authorTom Hughes <tom@compton.nu>
Sun, 7 Feb 2021 15:57:03 +0000 (15:57 +0000)
committerTom Hughes <tom@compton.nu>
Sun, 7 Feb 2021 16:24:14 +0000 (16:24 +0000)
Fixes #3085

app/views/changesets/history.html.erb
test/controllers/changesets_controller_test.rb

index f9eb01a6d69948d8911dec99cae609ff3b582af2..cb80787a7a6fa36a3f290734c05b562a5551ec79 100644 (file)
@@ -1,6 +1,6 @@
 <% content_for :auto_discovery_link_tag do -%>
   <% unless params[:friends] or params[:nearby] -%>
-    <%= auto_discovery_link_tag :atom, @params.merge(:max_id => nil, :xhr => nil, :action => :feed) %>
+    <%= auto_discovery_link_tag :atom, @params.to_h.merge(:max_id => nil, :xhr => nil, :action => :feed) %>
   <% end -%>
 <% end -%>
 
index a5ce2aa62ce8c60a8b29b864aafb0ca1729629f9..fbbb36f3fc664dc2c813781acd0ef77d13c1729d 100644 (file)
@@ -40,6 +40,9 @@ class ChangesetsControllerTest < ActionDispatch::IntegrationTest
     assert_template "history"
     assert_template :layout => "map"
     assert_select "h2", :text => "Changesets", :count => 1
+    assert_select "link[rel='alternate'][type='application/atom+xml']", :count => 1 do
+      assert_select "[href=?]", "http://www.example.com/history/feed"
+    end
 
     get history_path(:format => "html", :list => "1"), :xhr => true
     assert_response :success
@@ -58,6 +61,9 @@ class ChangesetsControllerTest < ActionDispatch::IntegrationTest
     assert_template "history"
     assert_template :layout => "xhr"
     assert_select "h2", :text => "Changesets", :count => 1
+    assert_select "link[rel='alternate'][type='application/atom+xml']", :count => 1 do
+      assert_select "[href=?]", "http://www.example.com/history/feed"
+    end
 
     get history_path(:format => "html", :list => "1"), :xhr => true
     assert_response :success
@@ -84,6 +90,9 @@ class ChangesetsControllerTest < ActionDispatch::IntegrationTest
     assert_template "history"
     assert_template :layout => "map"
     assert_select "h2", :text => "Changesets", :count => 1
+    assert_select "link[rel='alternate'][type='application/atom+xml']", :count => 1 do
+      assert_select "[href=?]", "http://www.example.com/history/feed?bbox=4.5%2C4.5%2C5.5%2C5.5"
+    end
 
     get history_path(:format => "html", :bbox => "4.5,4.5,5.5,5.5", :list => "1"), :xhr => true
     assert_response :success
@@ -102,6 +111,11 @@ class ChangesetsControllerTest < ActionDispatch::IntegrationTest
     get history_path(:format => "html", :display_name => user.display_name)
     assert_response :success
     assert_template "history"
+    assert_template :layout => "map"
+    assert_select "h2", :text => "Changesets by #{user.display_name}", :count => 1
+    assert_select "link[rel='alternate'][type='application/atom+xml']", :count => 1 do
+      assert_select "[href=?]", "http://www.example.com/user/#{ERB::Util.url_encode(user.display_name)}/history/feed"
+    end
 
     get history_path(:format => "html", :display_name => user.display_name, :list => "1"), :xhr => true
     assert_response :success