summaryrefslogtreecommitdiffstats
path: root/test/unit
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2008-07-26 11:46:24 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2008-07-26 11:46:24 +0000
commit60d066f943c68a348fee3a8350dc5ba88878b69c (patch)
tree00d123b7b25e7306688842a7fed0733412118f41 /test/unit
parentb68fd4c04bed4d8c9f7d0ad9d65125c36635c819 (diff)
downloadredmine-60d066f943c68a348fee3a8350dc5ba88878b69c.tar.gz
redmine-60d066f943c68a348fee3a8350dc5ba88878b69c.zip
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
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/wiki_page_test.rb44
1 files changed, 44 insertions, 0 deletions
diff --git a/test/unit/wiki_page_test.rb b/test/unit/wiki_page_test.rb
index bb8111176..e5ebeeea6 100644
--- a/test/unit/wiki_page_test.rb
+++ b/test/unit/wiki_page_test.rb
@@ -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