summaryrefslogtreecommitdiff
path: root/test/models/page_test.rb
diff options
context:
space:
mode:
authorerdgeist <erdgeist@erdgeist.org>2026-07-31 18:55:35 +0200
committererdgeist <erdgeist@erdgeist.org>2026-07-31 18:55:35 +0200
commit683526b38442a9873d83a542b5cba1d15efc14d5 (patch)
tree5cdf7d762d829d328e3c6437318d20af72bc65bf /test/models/page_test.rb
parent464af1625349d557f688da9f845471ef8b80a5f9 (diff)
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 <updated>, and the optional dc:date is omitted.
Diffstat (limited to 'test/models/page_test.rb')
-rw-r--r--test/models/page_test.rb20
1 files changed, 18 insertions, 2 deletions
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
9 9
10 def test_aggregation 10 def test_aggregation
11 # Create two nodes and move them beneath the root node 11 # Create two nodes and move them beneath the root node
12 n1 = Node.root.children.create! :slug => "one" 12 updates = Node.root.children.create! :slug => "updates"
13 n2 = Node.root.children.create! :slug => "two" 13 n1 = updates.children.create! :slug => "one"
14 n2 = updates.children.create! :slug => "two"
14 15
15 # get the drafts and assign a user to it 16 # get the drafts and assign a user to it
16 assert_not_nil d1 = find_or_create_draft(n1, @user1) 17 assert_not_nil d1 = find_or_create_draft(n1, @user1)
@@ -409,4 +410,19 @@ class PageTest < ActiveSupport::TestCase
409 page.reload 410 page.reload
410 assert page.update(:abstract => "still saveable") 411 assert page.update(:abstract => "still saveable")
411 end 412 end
413
414 test "an aggregate over a scoped tag ignores pages outside that subtree" do
415 updates = Node.root.children.create!(:slug => "updates")
416 inside = updates.children.create!(:slug => "inside-post")
417 outside = Node.root.children.create!(:slug => "outside-post")
418
419 [inside, outside].each do |node|
420 node.reload.draft.update!(:title => node.slug, :tag_list => "update")
421 node.publish_draft!
422 end
423
424 names = Page.aggregate({ :tags => "update" }).map { |p| p.node.unique_name }
425 assert_includes names, "updates/inside-post"
426 assert_not_includes names, "outside-post"
427 end
412end 428end