summaryrefslogtreecommitdiffstats
path: root/test/unit/issue_nested_set_test.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2016-12-21 10:35:36 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2016-12-21 10:35:36 +0000
commitb58cf253838bab9ef558b111b5094aae21890b45 (patch)
tree6fbd0e726f0af3de86cc8fab7a6259f81bc1f4d5 /test/unit/issue_nested_set_test.rb
parent5a0884c90f71a43dbb1c1b10508050cbe2707a4a (diff)
downloadredmine-b58cf253838bab9ef558b111b5094aae21890b45.tar.gz
redmine-b58cf253838bab9ef558b111b5094aae21890b45.zip
Adds .rebuild_single_tree! to rebuild a single tree (#24167).
git-svn-id: http://svn.redmine.org/redmine/trunk@16111 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/unit/issue_nested_set_test.rb')
-rw-r--r--test/unit/issue_nested_set_test.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/unit/issue_nested_set_test.rb b/test/unit/issue_nested_set_test.rb
index 88f65d3f6..4062839a3 100644
--- a/test/unit/issue_nested_set_test.rb
+++ b/test/unit/issue_nested_set_test.rb
@@ -306,4 +306,23 @@ class IssueNestedSetTest < ActiveSupport::TestCase
assert_equal ic2, ic4.parent
assert ic5.root?
end
+
+ def test_rebuild_single_tree
+ i1 = Issue.generate!
+ i2 = i1.generate_child!
+ i3 = i1.generate_child!
+ Issue.update_all(:lft => 7, :rgt => 7)
+
+ Issue.rebuild_single_tree!(i1.id)
+
+ i1.reload
+ assert_equal [1, 6], [i1.lft, i1.rgt]
+ i2.reload
+ assert_equal [2, 3], [i2.lft, i2.rgt]
+ i3.reload
+ assert_equal [4, 5], [i3.lft, i3.rgt]
+
+ other = Issue.find(1)
+ assert_equal [7, 7], [other.lft, other.rgt]
+ end
end