diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-11-23 17:50:46 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-11-23 17:50:46 +0000 |
commit | 25c63ec74727261c41bd1eec56a04a08e6a4ad07 (patch) | |
tree | 4ae25bcafb917ddaf39e91d88c2c8ada326b67fd /test | |
parent | 13f5301c097fab6b6865c739cfb4843cf7886c8a (diff) | |
download | redmine-25c63ec74727261c41bd1eec56a04a08e6a4ad07.tar.gz redmine-25c63ec74727261c41bd1eec56a04a08e6a4ad07.zip |
Adds a Project.rebuild_tree! method to force the rebuild of the nested set.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10867 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test')
-rw-r--r-- | test/unit/project_nested_set_test.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/test/unit/project_nested_set_test.rb b/test/unit/project_nested_set_test.rb index 3bd37609b..b038f30ac 100644 --- a/test/unit/project_nested_set_test.rb +++ b/test/unit/project_nested_set_test.rb @@ -54,6 +54,15 @@ class ProjectNestedSetTest < ActiveSupport::TestCase assert_valid_nested_set end + def test_rebuild_tree_should_build_valid_tree_even_with_valid_lft_rgt_values + Project.update_all "name = 'YY'", {:id => @a.id } + # lft and rgt values are still valid (Project.rebuild! would not update anything) + # but projects are not ordered properly (YY is in the first place) + + Project.rebuild_tree! + assert_valid_nested_set + end + def test_moving_a_child_to_a_different_parent_should_keep_valid_tree assert_no_difference 'Project.count' do Project.find_by_name('B1').set_parent!(Project.find_by_name('A2')) |