From 683526b38442a9873d83a542b5cba1d15efc14d5 Mon Sep 17 00:00:00 2001 From: erdgeist Date: Fri, 31 Jul 2026 18:55:35 +0200 Subject: Bind aggregates over scoped tags to their subtree CccConventions::TAG_SCOPES maps "update" and "pressemitteilung" to /updates and "disclosure" to /disclosure. Page.aggregate applies the mapping, so an aggregate over one of those tags is bounded by its subtree regardless of what the shortcode says. Tags stay unrestricted; positions are publish-gated. Both RSS actions call Page.aggregate rather than repeating its tag join. Empty feeds no longer crash: Atom falls back to the current time for the required , and the optional dc:date is omitted. --- test/models/page_test.rb | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'test/models') diff --git a/test/models/page_test.rb b/test/models/page_test.rb index 98a00d21..395b6315 100644 --- a/test/models/page_test.rb +++ b/test/models/page_test.rb @@ -9,8 +9,9 @@ class PageTest < ActiveSupport::TestCase def test_aggregation # Create two nodes and move them beneath the root node - n1 = Node.root.children.create! :slug => "one" - n2 = Node.root.children.create! :slug => "two" + updates = Node.root.children.create! :slug => "updates" + n1 = updates.children.create! :slug => "one" + n2 = updates.children.create! :slug => "two" # get the drafts and assign a user to it assert_not_nil d1 = find_or_create_draft(n1, @user1) @@ -409,4 +410,19 @@ class PageTest < ActiveSupport::TestCase page.reload assert page.update(:abstract => "still saveable") end + + test "an aggregate over a scoped tag ignores pages outside that subtree" do + updates = Node.root.children.create!(:slug => "updates") + inside = updates.children.create!(:slug => "inside-post") + outside = Node.root.children.create!(:slug => "outside-post") + + [inside, outside].each do |node| + node.reload.draft.update!(:title => node.slug, :tag_list => "update") + node.publish_draft! + end + + names = Page.aggregate({ :tags => "update" }).map { |p| p.node.unique_name } + assert_includes names, "updates/inside-post" + assert_not_includes names, "outside-post" + end end -- cgit v1.3