Wiki page hierarchy (#528). Parent page can be assigned on Rename screen.
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1698 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
1 parent
b68fd4c04b
commit
60d066f943
38 files changed
+139
-11
No files matched your search
Vendored
+5
-1
@@ -4,23 +4,27 @@ wiki_pages_001:
|
||||
title: CookBook_documentation
|
||||
id: 1
|
||||
wiki_id: 1
|
||||
protected: true
|
||||
protected: true
|
||||
parent_id:
|
||||
wiki_pages_002:
|
||||
created_on: 2007-03-08 00:18:07 +01:00
|
||||
title: Another_page
|
||||
id: 2
|
||||
wiki_id: 1
|
||||
protected: false
|
||||
parent_id:
|
||||
wiki_pages_003:
|
||||
created_on: 2007-03-08 00:18:07 +01:00
|
||||
title: Start_page
|
||||
id: 3
|
||||
wiki_id: 2
|
||||
protected: false
|
||||
parent_id:
|
||||
wiki_pages_004:
|
||||
created_on: 2007-03-08 00:18:07 +01:00
|
||||
title: Page_with_an_inline_image
|
||||
id: 4
|
||||
wiki_id: 1
|
||||
protected: false
|
||||
parent_id: 1
|
||||
|
||||
@@ -163,8 +163,16 @@ class WikiControllerTest < Test::Unit::TestCase
|
||||
pages = assigns(:pages)
|
||||
assert_not_nil pages
|
||||
assert_equal Project.find(1).wiki.pages.size, pages.size
|
||||
assert_tag :tag => 'a', :attributes => { :href => '/wiki/ecookbook/CookBook_documentation' },
|
||||
:content => /CookBook documentation/
|
||||
|
||||
assert_tag :ul, :attributes => { :class => 'pages-hierarchy' },
|
||||
:child => { :tag => 'li', :child => { :tag => 'a', :attributes => { :href => '/wiki/ecookbook/CookBook_documentation' },
|
||||
:content => 'CookBook documentation' },
|
||||
:child => { :tag => 'ul',
|
||||
:child => { :tag => 'li',
|
||||
:child => { :tag => 'a', :attributes => { :href => '/wiki/ecookbook/Page_with_an_inline_image' },
|
||||
:content => 'Page with an inline image' } } } },
|
||||
:child => { :tag => 'li', :child => { :tag => 'a', :attributes => { :href => '/wiki/ecookbook/Another_page' },
|
||||
:content => 'Another page' } }
|
||||
end
|
||||
|
||||
def test_not_found
|
||||
|
||||
@@ -48,6 +48,50 @@ class WikiPageTest < Test::Unit::TestCase
|
||||
assert page.new_record?
|
||||
end
|
||||
|
||||
def test_parent_title
|
||||
page = WikiPage.find_by_title('Another_page')
|
||||
assert_nil page.parent_title
|
||||
|
||||
page = WikiPage.find_by_title('Page_with_an_inline_image')
|
||||
assert_equal 'CookBook documentation', page.parent_title
|
||||
end
|
||||
|
||||
def test_assign_parent
|
||||
page = WikiPage.find_by_title('Another_page')
|
||||
page.parent_title = 'CookBook documentation'
|
||||
assert page.save
|
||||
page.reload
|
||||
assert_equal WikiPage.find_by_title('CookBook_documentation'), page.parent
|
||||
end
|
||||
|
||||
def test_unassign_parent
|
||||
page = WikiPage.find_by_title('Page_with_an_inline_image')
|
||||
page.parent_title = ''
|
||||
assert page.save
|
||||
page.reload
|
||||
assert_nil page.parent
|
||||
end
|
||||
|
||||
def test_parent_validation
|
||||
page = WikiPage.find_by_title('CookBook_documentation')
|
||||
|
||||
# A page that doesn't exist
|
||||
page.parent_title = 'Unknown title'
|
||||
assert !page.save
|
||||
assert_equal :activerecord_error_invalid, page.errors.on(:parent_title)
|
||||
# A child page
|
||||
page.parent_title = 'Page_with_an_inline_image'
|
||||
assert !page.save
|
||||
assert_equal :activerecord_error_circular_dependency, page.errors.on(:parent_title)
|
||||
# The page itself
|
||||
page.parent_title = 'CookBook_documentation'
|
||||
assert !page.save
|
||||
assert_equal :activerecord_error_circular_dependency, page.errors.on(:parent_title)
|
||||
|
||||
page.parent_title = 'Another_page'
|
||||
assert page.save
|
||||
end
|
||||
|
||||
def test_destroy
|
||||
page = WikiPage.find(1)
|
||||
page.destroy
|
||||
|
||||
Reference in new issue
Block a user