diff --git a/app/models/post.rb b/app/models/post.rb index 23d7bdf23..5e307b5ee 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -920,14 +920,7 @@ class Post < ApplicationRecord end def update_children_on_destroy - return unless children.present? - - eldest = children[0] - siblings = children[1..-1] - - eldest.update(parent_id: nil) - Post.where(id: siblings).find_each { |p| p.update(parent_id: eldest.id) } - # Post.where(id: siblings).update(parent_id: eldest.id) # XXX rails 5 + children.update(parent: nil) end def update_parent_on_save diff --git a/test/unit/post_test.rb b/test/unit/post_test.rb index d8349b44f..3fb4caf65 100644 --- a/test/unit/post_test.rb +++ b/test/unit/post_test.rb @@ -254,17 +254,6 @@ class PostTest < ActiveSupport::TestCase end end - should "reparent all children to the first child" do - @p1.expunge! - @c1.reload - @c2.reload - @c3.reload - - assert_nil(@c1.parent_id) - assert_equal(@c1.id, @c2.parent_id) - assert_equal(@c1.id, @c3.parent_id) - end - should "save a post version record for each child" do assert_difference(["@c1.versions.count", "@c2.versions.count", "@c3.versions.count"]) do @p1.expunge! @@ -273,11 +262,6 @@ class PostTest < ActiveSupport::TestCase @c3.reload end end - - should "set the has_children flag on the new parent" do - @p1.expunge! - assert_equal(true, @c1.reload.has_children?) - end end end