@@ -1316,8 +1316,7 class Issue < ActiveRecord::Base | |||
|
1316 | 1316 | self.root_id = (@parent_issue.nil? ? id : @parent_issue.root_id) |
|
1317 | 1317 | cond = ["root_id = ? AND lft >= ? AND rgt <= ? ", old_root_id, lft, rgt] |
|
1318 | 1318 | self.class.base_class.select('id').lock(true).where(cond) |
|
1319 | target_maxright = nested_set_scope.maximum(right_column_name) || 0 | |
|
1320 | offset = target_maxright + 1 - lft | |
|
1319 | offset = right_most_bound + 1 - lft | |
|
1321 | 1320 | Issue.where(cond). |
|
1322 | 1321 | update_all(["root_id = ?, lft = lft + ?, rgt = rgt + ?", root_id, offset, offset]) |
|
1323 | 1322 | self[left_column_name] = lft + offset |
@@ -86,6 +86,7 class IssueNestedSetTest < ActiveSupport::TestCase | |||
|
86 | 86 | parent1 = Issue.generate! |
|
87 | 87 | lft2 = new_issue_lft |
|
88 | 88 | parent2 = Issue.generate! |
|
89 | lft3 = new_issue_lft | |
|
89 | 90 | child = parent1.generate_child! |
|
90 | 91 | child.parent_issue_id = nil |
|
91 | 92 | child.save! |
@@ -94,7 +95,7 class IssueNestedSetTest < ActiveSupport::TestCase | |||
|
94 | 95 | parent2.reload |
|
95 | 96 | assert_equal [parent1.id, lft1, lft1 + 1], [parent1.root_id, parent1.lft, parent1.rgt] |
|
96 | 97 | assert_equal [parent2.id, lft2, lft2 + 1], [parent2.root_id, parent2.lft, parent2.rgt] |
|
97 |
assert_equal [child.id, 1 |
|
|
98 | assert_equal [child.id, lft3, lft3 + 1], [child.root_id, child.lft, child.rgt] | |
|
98 | 99 | end |
|
99 | 100 | |
|
100 | 101 | def test_move_a_child_to_another_issue |
@@ -145,6 +146,7 class IssueNestedSetTest < ActiveSupport::TestCase | |||
|
145 | 146 | parent1 = Issue.generate! |
|
146 | 147 | child = parent1.generate_child! |
|
147 | 148 | grandchild = child.generate_child! |
|
149 | lft4 = new_issue_lft | |
|
148 | 150 | child.reload |
|
149 | 151 | child.project = Project.find(2) |
|
150 | 152 | assert child.save |
@@ -152,8 +154,10 class IssueNestedSetTest < ActiveSupport::TestCase | |||
|
152 | 154 | grandchild.reload |
|
153 | 155 | parent1.reload |
|
154 | 156 | assert_equal [1, parent1.id, lft1, lft1 + 1], [parent1.project_id, parent1.root_id, parent1.lft, parent1.rgt] |
|
155 | assert_equal [2, child.id, 1, 4], [child.project_id, child.root_id, child.lft, child.rgt] | |
|
156 |
|
|
|
157 | assert_equal [2, child.id, lft4, lft4 + 3], | |
|
158 | [child.project_id, child.root_id, child.lft, child.rgt] | |
|
159 | assert_equal [2, child.id, lft4 + 1, lft4 + 2], | |
|
160 | [grandchild.project_id, grandchild.root_id, grandchild.lft, grandchild.rgt] | |
|
157 | 161 | end |
|
158 | 162 | |
|
159 | 163 | def test_moving_an_issue_to_a_descendant_should_not_validate |
General Comments 0
You need to be logged in to leave comments.
Login now