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/controllers/content_controller_test.rb | 23 +++++++++++------------ test/controllers/rss_controller_test.rb | 20 +++++++++++++++++++- 2 files changed, 30 insertions(+), 13 deletions(-) (limited to 'test/controllers') diff --git a/test/controllers/content_controller_test.rb b/test/controllers/content_controller_test.rb index 5bb02f3d..39fe276b 100644 --- a/test/controllers/content_controller_test.rb +++ b/test/controllers/content_controller_test.rb @@ -239,17 +239,16 @@ class ContentControllerTest < ActionController::TestCase end def fill_pages_with_content - d1 = find_or_create_draft(@first_child, @user1) - d1.title = "one" - d1.tag_list = "update" - d1.save - @first_child.publish_draft! - - d2 = find_or_create_draft(@second_child, @user1) - d2.title = "two" - d2.tag_list = "update" - d2.save - @second_child.publish_draft! + updates = Node.root.children.find_by(:slug => "updates") || + Node.root.children.create!(:slug => "updates") + + [["one", "aggregated_one"], ["two", "aggregated_two"]].each do |title, slug| + node = updates.children.create!(:slug => slug) + draft = find_or_create_draft(node, @user1) + draft.title = title + draft.tag_list = "update" + draft.save + node.publish_draft! + end end - end diff --git a/test/controllers/rss_controller_test.rb b/test/controllers/rss_controller_test.rb index 3f4b4fbf..cf50903a 100644 --- a/test/controllers/rss_controller_test.rb +++ b/test/controllers/rss_controller_test.rb @@ -5,7 +5,9 @@ class RssControllerTest < ActionController::TestCase def setup @user = User.create :login => 'rsstest', :email => 'rsstest@example.com', :password => 'foobar', :password_confirmation => 'foobar' - @node = Node.root.children.create! :slug => 'rss_test_node' + updates = Node.root.children.find_by(:slug => "updates") || + Node.root.children.create!(:slug => "updates") + @node = updates.children.create! :slug => 'rss_test_node' draft = find_or_create_draft(@node, @user) draft.title = "RSS Update Article" draft.tag_list = "update" @@ -31,4 +33,20 @@ class RssControllerTest < ActionController::TestCase assert assigns(:items).length <= 20 end + test "the update feed excludes a page tagged update outside /updates" do + updates = Node.root.children.find_by(:slug => "updates") + inside = updates.children.create!(:slug => "feed-inside") + outside = Node.root.children.create!(:slug => "feed-outside") + + [inside, outside].each do |node| + node.reload.draft.update!(:title => node.slug, :tag_list => "update") + node.publish_draft! + end + + get :updates, params: { :format => :xml } + + assert_response :success + assert_includes @response.body, "feed-inside" + assert_not_includes @response.body, "feed-outside" + end end -- cgit v1.3