Fix #5293: NoMethodError in sitemap when relation is empty.
This commit is contained in:
@@ -74,11 +74,32 @@ Allow: /sitemap.xml
|
|||||||
Allow: /favicon.ico
|
Allow: /favicon.ico
|
||||||
Allow: /favicon.svg
|
Allow: /favicon.svg
|
||||||
|
|
||||||
|
<% if Artist.undeleted.exists? %>
|
||||||
Sitemap: <%= sitemap_url(format: :xml, sitemap: "artists") %>
|
Sitemap: <%= sitemap_url(format: :xml, sitemap: "artists") %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<% if ForumTopic.undeleted.exists? %>
|
||||||
Sitemap: <%= sitemap_url(format: :xml, sitemap: "forum_topics") %>
|
Sitemap: <%= sitemap_url(format: :xml, sitemap: "forum_topics") %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<% if Pool.undeleted.exists? %>
|
||||||
Sitemap: <%= sitemap_url(format: :xml, sitemap: "pools") %>
|
Sitemap: <%= sitemap_url(format: :xml, sitemap: "pools") %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<% if Post.exists? %>
|
||||||
Sitemap: <%= sitemap_url(format: :xml, sitemap: "posts") %>
|
Sitemap: <%= sitemap_url(format: :xml, sitemap: "posts") %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<% if Tag.nonempty.exists? %>
|
||||||
Sitemap: <%= sitemap_url(format: :xml, sitemap: "tags") %>
|
Sitemap: <%= sitemap_url(format: :xml, sitemap: "tags") %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<% if User.exists? %>
|
||||||
Sitemap: <%= sitemap_url(format: :xml, sitemap: "users") %>
|
Sitemap: <%= sitemap_url(format: :xml, sitemap: "users") %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<% if WikiPage.undeleted.exists? %>
|
||||||
Sitemap: <%= sitemap_url(format: :xml, sitemap: "wiki_pages") %>
|
Sitemap: <%= sitemap_url(format: :xml, sitemap: "wiki_pages") %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
<% end %>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
||||||
<% 0.upto(@relation.maximum(:id) / @limit) do |page| %>
|
<% 0.upto(@relation.maximum(:id).to_i / @limit) do |page| %>
|
||||||
<% lo = page * @limit %>
|
<% lo = page * @limit %>
|
||||||
<% hi = (page + 1) * @limit %>
|
<% hi = (page + 1) * @limit %>
|
||||||
<% lastmod = @relation.where(id: lo..hi).maximum(:updated_at)&.iso8601 %>
|
<% lastmod = @relation.where(id: lo..hi).maximum(:updated_at)&.iso8601 %>
|
||||||
|
|||||||
@@ -23,6 +23,12 @@ class StaticControllerTest < ActionDispatch::IntegrationTest
|
|||||||
assert_equal(1, response.parsed_body.css("sitemap loc").size)
|
assert_equal(1, response.parsed_body.css("sitemap loc").size)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
should "work when the sitemap is empty" do
|
||||||
|
get sitemap_path(sitemap: "pools"), as: :xml
|
||||||
|
|
||||||
|
assert_response :success
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "dtext_help action" do
|
context "dtext_help action" do
|
||||||
|
|||||||
Reference in New Issue
Block a user