summaryrefslogtreecommitdiffstats
path: root/test/unit/wiki_page_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/unit/wiki_page_test.rb')
-rw-r--r--test/unit/wiki_page_test.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/unit/wiki_page_test.rb b/test/unit/wiki_page_test.rb
index a8c56678d..d3453583c 100644
--- a/test/unit/wiki_page_test.rb
+++ b/test/unit/wiki_page_test.rb
@@ -101,6 +101,26 @@ class WikiPageTest < ActiveSupport::TestCase
assert page.save
end
+ def test_move_child_should_clear_parent
+ parent = WikiPage.create!(:wiki_id => 1, :title => 'Parent')
+ child = WikiPage.create!(:wiki_id => 1, :title => 'Child', :parent => parent)
+
+ child.wiki_id = 2
+ child.save!
+ assert_equal nil, child.reload.parent_id
+ end
+
+ def test_move_parent_should_move_child_page
+ parent = WikiPage.create!(:wiki_id => 1, :title => 'Parent')
+ child = WikiPage.create!(:wiki_id => 1, :title => 'Child', :parent => parent)
+ parent.reload
+
+ parent.wiki_id = 2
+ parent.save!
+ assert_equal 2, child.reload.wiki_id
+ assert_equal parent, child.parent
+ end
+
def test_destroy
page = WikiPage.find(1)
page.destroy