@@ -126,7 +126,7 class WikiPage < ActiveRecord::Base | |||||
126 | child.wiki_id = wiki_id |
|
126 | child.wiki_id = wiki_id | |
127 | child.redirect_existing_links = redirect_existing_links |
|
127 | child.redirect_existing_links = redirect_existing_links | |
128 | unless child.save |
|
128 | unless child.save | |
129 |
WikiPage.where(:id => child.id).update_all :parent_ |
|
129 | WikiPage.where(:id => child.id).update_all :parent_id => nil | |
130 | end |
|
130 | end | |
131 | end |
|
131 | end | |
132 | end |
|
132 | end |
@@ -121,6 +121,24 class WikiPageTest < ActiveSupport::TestCase | |||||
121 | assert_equal parent, child.parent |
|
121 | assert_equal parent, child.parent | |
122 | end |
|
122 | end | |
123 |
|
123 | |||
|
124 | def test_move_parent_with_child_with_duplicate_name_should_not_move_child | |||
|
125 | parent = WikiPage.create!(:wiki_id => 1, :title => 'Parent') | |||
|
126 | child = WikiPage.create!(:wiki_id => 1, :title => 'Child', :parent_id => parent.id) | |||
|
127 | parent.reload | |||
|
128 | # page with the same name as the child in the target wiki | |||
|
129 | WikiPage.create!(:wiki_id => 2, :title => 'Child') | |||
|
130 | ||||
|
131 | parent.wiki_id = 2 | |||
|
132 | parent.save! | |||
|
133 | ||||
|
134 | parent.reload | |||
|
135 | assert_equal 2, parent.wiki_id | |||
|
136 | ||||
|
137 | child.reload | |||
|
138 | assert_equal 1, child.wiki_id | |||
|
139 | assert_nil child.parent_id | |||
|
140 | end | |||
|
141 | ||||
124 | def test_destroy |
|
142 | def test_destroy | |
125 | page = WikiPage.find(1) |
|
143 | page = WikiPage.find(1) | |
126 | page.destroy |
|
144 | page.destroy |
General Comments 0
You need to be logged in to leave comments.
Login now