summaryrefslogtreecommitdiffstats
path: root/test/unit/wiki_page_test.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2016-01-30 15:12:13 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2016-01-30 15:12:13 +0000
commitf4bcb1286e21795719ff8257fe5561d141f8706e (patch)
treed3f7813ba791f8aebb89964bb00e4b73c7c4ba9b /test/unit/wiki_page_test.rb
parentc263d8030ad689f4eaed25728b1f22e45f400575 (diff)
downloadredmine-f4bcb1286e21795719ff8257fe5561d141f8706e.tar.gz
redmine-f4bcb1286e21795719ff8257fe5561d141f8706e.zip
Fixed that moving a wiki page with a child raises an error when target wiki contains a page with the same name as the child (#21900).
git-svn-id: http://svn.redmine.org/redmine/trunk@15130 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/unit/wiki_page_test.rb')
-rw-r--r--test/unit/wiki_page_test.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/unit/wiki_page_test.rb b/test/unit/wiki_page_test.rb
index 5fb184175..518db078d 100644
--- a/test/unit/wiki_page_test.rb
+++ b/test/unit/wiki_page_test.rb
@@ -121,6 +121,24 @@ class WikiPageTest < ActiveSupport::TestCase
assert_equal parent, child.parent
end
+ def test_move_parent_with_child_with_duplicate_name_should_not_move_child
+ parent = WikiPage.create!(:wiki_id => 1, :title => 'Parent')
+ child = WikiPage.create!(:wiki_id => 1, :title => 'Child', :parent_id => parent.id)
+ parent.reload
+ # page with the same name as the child in the target wiki
+ WikiPage.create!(:wiki_id => 2, :title => 'Child')
+
+ parent.wiki_id = 2
+ parent.save!
+
+ parent.reload
+ assert_equal 2, parent.wiki_id
+
+ child.reload
+ assert_equal 1, child.wiki_id
+ assert_nil child.parent_id
+ end
+
def test_destroy
page = WikiPage.find(1)
page.destroy