mirror of
https://github.com/meineerde/redmine.git
synced 2025-12-19 15:01:14 +00:00
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
This commit is contained in:
parent
c263d8030a
commit
f4bcb1286e
@ -126,7 +126,7 @@ class WikiPage < ActiveRecord::Base
|
|||||||
child.wiki_id = wiki_id
|
child.wiki_id = wiki_id
|
||||||
child.redirect_existing_links = redirect_existing_links
|
child.redirect_existing_links = redirect_existing_links
|
||||||
unless child.save
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -121,6 +121,24 @@ class WikiPageTest < ActiveSupport::TestCase
|
|||||||
assert_equal parent, child.parent
|
assert_equal parent, child.parent
|
||||||
end
|
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
|
def test_destroy
|
||||||
page = WikiPage.find(1)
|
page = WikiPage.find(1)
|
||||||
page.destroy
|
page.destroy
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user