Adds a "depth" option to the child_pages macro (#10789).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10401 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -131,4 +131,22 @@ class WikiPageTest < ActiveSupport::TestCase
|
||||
assert_equal Time.gm(2007, 3, 6, 23, 10, 51), page.content.updated_on
|
||||
assert_equal page.content.updated_on, page.updated_on
|
||||
end
|
||||
|
||||
def test_descendants
|
||||
page = WikiPage.create!(:wiki => @wiki, :title => 'Parent')
|
||||
child1 = WikiPage.create!(:wiki => @wiki, :title => 'Child1', :parent => page)
|
||||
child11 = WikiPage.create!(:wiki => @wiki, :title => 'Child11', :parent => child1)
|
||||
child111 = WikiPage.create!(:wiki => @wiki, :title => 'Child111', :parent => child11)
|
||||
child2 = WikiPage.create!(:wiki => @wiki, :title => 'Child2', :parent => page)
|
||||
|
||||
assert_equal %w(Child1 Child11 Child111 Child2), page.descendants.map(&:title).sort
|
||||
assert_equal %w(Child1 Child11 Child111 Child2), page.descendants(nil).map(&:title).sort
|
||||
assert_equal %w(Child1 Child11 Child2), page.descendants(2).map(&:title).sort
|
||||
assert_equal %w(Child1 Child2), page.descendants(1).map(&:title).sort
|
||||
|
||||
assert_equal %w(Child1 Child11 Child111 Child2 Parent), page.self_and_descendants.map(&:title).sort
|
||||
assert_equal %w(Child1 Child11 Child111 Child2 Parent), page.self_and_descendants(nil).map(&:title).sort
|
||||
assert_equal %w(Child1 Child11 Child2 Parent), page.self_and_descendants(2).map(&:title).sort
|
||||
assert_equal %w(Child1 Child2 Parent), page.self_and_descendants(1).map(&:title).sort
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user