From 8a84825b02ffbbf9ca669d255b419a9d8a862d2a Mon Sep 17 00:00:00 2001 From: Anton Khorev Date: Sun, 24 Mar 2024 05:01:05 +0300 Subject: [PATCH 1/1] Fix changeset comments feed timeout --- .../feeds/timeout.atom.builder | 12 ----------- .../changeset_comments/feeds/timeout.html.erb | 1 - .../feeds/timeout.rss.builder | 12 +++++++++++ .../feeds_controller_test.rb | 20 +++++++++++++++++++ 4 files changed, 32 insertions(+), 13 deletions(-) delete mode 100644 app/views/changeset_comments/feeds/timeout.atom.builder delete mode 100644 app/views/changeset_comments/feeds/timeout.html.erb create mode 100644 app/views/changeset_comments/feeds/timeout.rss.builder diff --git a/app/views/changeset_comments/feeds/timeout.atom.builder b/app/views/changeset_comments/feeds/timeout.atom.builder deleted file mode 100644 index b5eeeed4a..000000000 --- a/app/views/changeset_comments/feeds/timeout.atom.builder +++ /dev/null @@ -1,12 +0,0 @@ -atom_feed(:language => I18n.locale, :schema_date => 2009, - :id => url_for(params.merge(:only_path => false)), - :root_url => url_for(params.merge(:only_path => false, :format => nil)), - "xmlns:georss" => "http://www.georss.org/georss") do |feed| - feed.title @title - - feed.subtitle :type => "xhtml" do |xhtml| - xhtml.p do |p| - p << t(".sorry") - end - end -end diff --git a/app/views/changeset_comments/feeds/timeout.html.erb b/app/views/changeset_comments/feeds/timeout.html.erb deleted file mode 100644 index 641b1dfb8..000000000 --- a/app/views/changeset_comments/feeds/timeout.html.erb +++ /dev/null @@ -1 +0,0 @@ -

<%= t ".sorry" %>

diff --git a/app/views/changeset_comments/feeds/timeout.rss.builder b/app/views/changeset_comments/feeds/timeout.rss.builder new file mode 100644 index 000000000..c56ebb879 --- /dev/null +++ b/app/views/changeset_comments/feeds/timeout.rss.builder @@ -0,0 +1,12 @@ +xml.rss("version" => "2.0", + "xmlns:dc" => "http://purl.org/dc/elements/1.1/") do + xml.channel do + if params[:changeset_id] + xml.title t("changeset_comments.feeds.show.title_particular", :changeset_id => params[:changeset_id]) + else + xml.title t("changeset_comments.feeds.show.title_all") + end + xml.link root_url + xml.description t(".sorry") + end +end diff --git a/test/controllers/changeset_comments/feeds_controller_test.rb b/test/controllers/changeset_comments/feeds_controller_test.rb index 20db62cef..4858eb085 100644 --- a/test/controllers/changeset_comments/feeds_controller_test.rb +++ b/test/controllers/changeset_comments/feeds_controller_test.rb @@ -68,5 +68,25 @@ module ChangesetComments get changesets_comments_feed_path(:format => "rss", :limit => 100001) assert_response :bad_request end + + def test_feed_timeout + with_settings(:web_timeout => -1) do + get changesets_comments_feed_path + end + assert_response :error + assert_equal "application/rss+xml; charset=utf-8", @response.header["Content-Type"] + assert_dom "rss>channel>title", :text => "OpenStreetMap changeset discussion" + assert_dom "rss>channel>description", :text => /the list of changeset comments you requested took too long to retrieve/ + end + + def test_feed_changeset_timeout + with_settings(:web_timeout => -1) do + get changeset_comments_feed_path(123) + end + assert_response :error + assert_equal "application/rss+xml; charset=utf-8", @response.header["Content-Type"] + assert_dom "rss>channel>title", :text => "OpenStreetMap changeset #123 discussion" + assert_dom "rss>channel>description", :text => /the list of changeset comments you requested took too long to retrieve/ + end end end -- 2.39.5