diff --git a/app/views/static/sitemap_index.xml.erb b/app/views/static/sitemap_index.xml.erb index d779d41f7..eaae89833 100644 --- a/app/views/static/sitemap_index.xml.erb +++ b/app/views/static/sitemap_index.xml.erb @@ -4,7 +4,7 @@ <% 0.upto(@relation.maximum(:id) / @limit) do |page| %> <% lo = page * @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 %> <% if @sitemap == "posts" %> <% loc = posts_url(limit: @limit, format: :sitemap, tags: "id:#{lo}..#{hi}") %> <% else %> diff --git a/test/unit/post_sets/post_test.rb b/test/unit/post_sets/post_test.rb index 146600981..77f88800a 100644 --- a/test/unit/post_sets/post_test.rb +++ b/test/unit/post_sets/post_test.rb @@ -129,6 +129,7 @@ module PostSets context "that has a matching artist" do setup do + Tag.find_by(name: "a").update!(category: Tag.categories.artist) @artist = FactoryBot.create(:artist, :name => "a") end