diff options
Diffstat (limited to 'test/models')
| -rw-r--r-- | test/models/page_test.rb | 20 |
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 | ||
| 412 | end | 428 | end |
