summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2016-03-12 08:24:42 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2016-03-12 08:24:42 +0000
commit557861047b5ba84d8ed6c1fb38a28ba2deaca80c (patch)
tree17175058c5d58c72514cdb5e7d26ee4143b37d30
parent29a61daf39a6374aac33ab0bedd8780bde1a08cb (diff)
downloadredmine-557861047b5ba84d8ed6c1fb38a28ba2deaca80c.tar.gz
redmine-557861047b5ba84d8ed6c1fb38a28ba2deaca80c.zip
Merged r15130 (#21900).
git-svn-id: http://svn.redmine.org/redmine/branches/3.1-stable@15198 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--app/models/wiki_page.rb2
-rw-r--r--test/unit/wiki_page_test.rb18
2 files changed, 19 insertions, 1 deletions
diff --git a/app/models/wiki_page.rb b/app/models/wiki_page.rb
index ff8a12a99..e6639021c 100644
--- a/app/models/wiki_page.rb
+++ b/app/models/wiki_page.rb
@@ -127,7 +127,7 @@ class WikiPage < ActiveRecord::Base
child.wiki_id = wiki_id
child.redirect_existing_links = redirect_existing_links
unless child.save
- WikiPage.where(:id => child.id).update_all :parent_nil => nil
+ WikiPage.where(:id => child.id).update_all :parent_id => nil
end
end
end
diff --git a/test/unit/wiki_page_test.rb b/test/unit/wiki_page_test.rb
index 68e77a2e5..d1557c207 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