@@ -421,6 +421,7 class Project < ActiveRecord::Base | |||||
421 | transaction do |
|
421 | transaction do | |
422 | update_all "lft = NULL, rgt = NULL" |
|
422 | update_all "lft = NULL, rgt = NULL" | |
423 | rebuild!(false) |
|
423 | rebuild!(false) | |
|
424 | all.each { |p| p.set_or_update_position_under(p.parent) } | |||
424 | end |
|
425 | end | |
425 | end |
|
426 | end | |
426 |
|
427 | |||
@@ -1017,6 +1018,8 class Project < ActiveRecord::Base | |||||
1017 | set_or_update_position_under(parent) |
|
1018 | set_or_update_position_under(parent) | |
1018 | end |
|
1019 | end | |
1019 |
|
1020 | |||
|
1021 | public | |||
|
1022 | ||||
1020 | # Inserts/moves the project so that target's children or root projects stay alphabetically sorted |
|
1023 | # Inserts/moves the project so that target's children or root projects stay alphabetically sorted | |
1021 | def set_or_update_position_under(target_parent) |
|
1024 | def set_or_update_position_under(target_parent) | |
1022 | parent_was = parent |
|
1025 | parent_was = parent |
@@ -50,7 +50,7 class ProjectNestedSetTest < ActiveSupport::TestCase | |||||
50 | def test_rebuild_should_build_valid_tree |
|
50 | def test_rebuild_should_build_valid_tree | |
51 | Project.update_all "lft = NULL, rgt = NULL" |
|
51 | Project.update_all "lft = NULL, rgt = NULL" | |
52 |
|
52 | |||
53 | Project.rebuild! |
|
53 | Project.rebuild_tree! | |
54 | assert_valid_nested_set |
|
54 | assert_valid_nested_set | |
55 | end |
|
55 | end | |
56 |
|
56 |
General Comments 0
You need to be logged in to leave comments.
Login now