From: Tom Hughes Date: Sun, 18 Feb 2024 18:42:12 +0000 (+0000) Subject: Merge remote-tracking branch 'upstream/pull/4522' X-Git-Tag: live~1203 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/bf81e537ab0f6eca5e8fef3d6accbca3f09b3d8b?hp=d22e851557581fe92d837fb99705e5541582c9fe Merge remote-tracking branch 'upstream/pull/4522' --- diff --git a/app/views/changesets/index.atom.builder b/app/views/changesets/index.atom.builder index a1af72b91..b37fee367 100644 --- a/app/views/changesets/index.atom.builder +++ b/app/views/changesets/index.atom.builder @@ -25,7 +25,7 @@ atom_feed(:language => I18n.locale, :schema_date => 2009, :type => "application/osmChange+xml" if !changeset.tags.empty? && changeset.tags.key?("comment") - entry.title t("browse.changeset.feed.title_comment", :id => changeset.id, :comment => changeset.tags["comment"]), :type => "html" + entry.title t("browse.changeset.feed.title_comment", :id => changeset.id, :comment => changeset.tags["comment"]) else entry.title t("browse.changeset.feed.title", :id => changeset.id) end diff --git a/test/controllers/changesets_controller_test.rb b/test/controllers/changesets_controller_test.rb index d9a4b256b..778a6024c 100644 --- a/test/controllers/changesets_controller_test.rb +++ b/test/controllers/changesets_controller_test.rb @@ -243,6 +243,7 @@ class ChangesetsControllerTest < ActionDispatch::IntegrationTest create(:changeset_tag, :changeset => changeset) create(:changeset_tag, :changeset => changeset, :k => "website", :v => "http://example.com/") closed_changeset = create(:changeset, :closed, :num_changes => 1) + create(:changeset_tag, :changeset => closed_changeset, :k => "website", :v => "https://osm.org/") _empty_changeset = create(:changeset, :num_changes => 0) get history_feed_path(:format => :atom) @@ -250,7 +251,19 @@ class ChangesetsControllerTest < ActionDispatch::IntegrationTest assert_template "index" assert_equal "application/atom+xml", response.media_type - check_feed_result([changeset, closed_changeset]) + check_feed_result([closed_changeset, changeset]) + end + + def test_feed_with_comment_tag + changeset = create(:changeset, :num_changes => 1) + create(:changeset_tag, :changeset => changeset, :k => "comment", :v => "tested-changeset-comment") + + get history_feed_path(:format => :atom) + assert_response :success + assert_template "index" + assert_equal "application/atom+xml", response.media_type + + check_feed_result([changeset]) end ## @@ -268,7 +281,7 @@ class ChangesetsControllerTest < ActionDispatch::IntegrationTest assert_template "index" assert_equal "application/atom+xml", response.media_type - check_feed_result([changeset, closed_changeset]) + check_feed_result([closed_changeset, changeset]) end ## @@ -286,7 +299,7 @@ class ChangesetsControllerTest < ActionDispatch::IntegrationTest assert_template "index" assert_equal "application/atom+xml", response.media_type - check_feed_result(changesets) + check_feed_result(changesets.reverse) end ## @@ -325,15 +338,26 @@ class ChangesetsControllerTest < ActionDispatch::IntegrationTest assert_select "feed", :count => [changesets.size, 1].min do assert_select "> title", :count => 1, :text => /^Changesets/ - assert_select "> entry", :count => changesets.size - - changesets.each do |changeset| - assert_select "> entry > id", changeset_url(:id => changeset.id) + assert_select "> entry", :count => changesets.size do |entries| + entries.zip(changesets) do |entry, changeset| + assert_select entry, "> id", :text => changeset_url(:id => changeset.id) + + changeset_comment = changeset.tags["comment"] + if changeset_comment + assert_select entry, "> title", :count => 1, :text => "Changeset #{changeset.id} - #{changeset_comment}" + else + assert_select entry, "> title", :count => 1, :text => "Changeset #{changeset.id}" + end - assert_select "> entry > content > xhtml|div > xhtml|table" do - assert_select "> xhtml|tr > xhtml|td > xhtml|table" do - changeset.tags.each_key do |key| - assert_select "> xhtml|tr > xhtml|td", :text => /^#{key} = / + assert_select entry, "> content > xhtml|div > xhtml|table" do + if changeset.tags.empty? + assert_select "> xhtml|tr > xhtml|td > xhtml|table", :count => 0 + else + assert_select "> xhtml|tr > xhtml|td > xhtml|table", :count => 1 do + changeset.tags.each_key do |key| + assert_select "> xhtml|tr > xhtml|td", :text => /^#{key} = / + end + end end end end