diff options
| author | erdgeist <erdgeist@erdgeist.org> | 2026-07-31 18:55:35 +0200 |
|---|---|---|
| committer | erdgeist <erdgeist@erdgeist.org> | 2026-07-31 18:55:35 +0200 |
| commit | 683526b38442a9873d83a542b5cba1d15efc14d5 (patch) | |
| tree | 5cdf7d762d829d328e3c6437318d20af72bc65bf /test | |
| parent | 464af1625349d557f688da9f845471ef8b80a5f9 (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')
| -rw-r--r-- | test/controllers/content_controller_test.rb | 21 | ||||
| -rw-r--r-- | test/controllers/rss_controller_test.rb | 20 | ||||
| -rw-r--r-- | test/models/page_test.rb | 20 |
3 files changed, 47 insertions, 14 deletions
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 | |||
| 239 | end | 239 | end |
| 240 | 240 | ||
| 241 | def fill_pages_with_content | 241 | def fill_pages_with_content |
| 242 | d1 = find_or_create_draft(@first_child, @user1) | 242 | updates = Node.root.children.find_by(:slug => "updates") || |
| 243 | d1.title = "one" | 243 | Node.root.children.create!(:slug => "updates") |
| 244 | d1.tag_list = "update" | ||
| 245 | d1.save | ||
| 246 | @first_child.publish_draft! | ||
| 247 | 244 | ||
| 248 | d2 = find_or_create_draft(@second_child, @user1) | 245 | [["one", "aggregated_one"], ["two", "aggregated_two"]].each do |title, slug| |
| 249 | d2.title = "two" | 246 | node = updates.children.create!(:slug => slug) |
| 250 | d2.tag_list = "update" | 247 | draft = find_or_create_draft(node, @user1) |
| 251 | d2.save | 248 | draft.title = title |
| 252 | @second_child.publish_draft! | 249 | draft.tag_list = "update" |
| 250 | draft.save | ||
| 251 | node.publish_draft! | ||
| 252 | end | ||
| 253 | end | 253 | end |
| 254 | |||
| 255 | end | 254 | 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 | |||
| 5 | def setup | 5 | def setup |
| 6 | @user = User.create :login => 'rsstest', :email => 'rsstest@example.com', | 6 | @user = User.create :login => 'rsstest', :email => 'rsstest@example.com', |
| 7 | :password => 'foobar', :password_confirmation => 'foobar' | 7 | :password => 'foobar', :password_confirmation => 'foobar' |
| 8 | @node = Node.root.children.create! :slug => 'rss_test_node' | 8 | updates = Node.root.children.find_by(:slug => "updates") || |
| 9 | Node.root.children.create!(:slug => "updates") | ||
| 10 | @node = updates.children.create! :slug => 'rss_test_node' | ||
| 9 | draft = find_or_create_draft(@node, @user) | 11 | draft = find_or_create_draft(@node, @user) |
| 10 | draft.title = "RSS Update Article" | 12 | draft.title = "RSS Update Article" |
| 11 | draft.tag_list = "update" | 13 | draft.tag_list = "update" |
| @@ -31,4 +33,20 @@ class RssControllerTest < ActionController::TestCase | |||
| 31 | assert assigns(:items).length <= 20 | 33 | assert assigns(:items).length <= 20 |
| 32 | end | 34 | end |
| 33 | 35 | ||
| 36 | test "the update feed excludes a page tagged update outside /updates" do | ||
| 37 | updates = Node.root.children.find_by(:slug => "updates") | ||
| 38 | inside = updates.children.create!(:slug => "feed-inside") | ||
| 39 | outside = Node.root.children.create!(:slug => "feed-outside") | ||
| 40 | |||
| 41 | [inside, outside].each do |node| | ||
| 42 | node.reload.draft.update!(:title => node.slug, :tag_list => "update") | ||
| 43 | node.publish_draft! | ||
| 44 | end | ||
| 45 | |||
| 46 | get :updates, params: { :format => :xml } | ||
| 47 | |||
| 48 | assert_response :success | ||
| 49 | assert_includes @response.body, "feed-inside" | ||
| 50 | assert_not_includes @response.body, "feed-outside" | ||
| 51 | end | ||
| 34 | end | 52 | end |
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 | ||
| 412 | end | 428 | end |
