From 1122fd0e6aacef0543c12cdcfccf7b72b242dee7 Mon Sep 17 00:00:00 2001 From: Toshi MARUYAMA Date: Tue, 17 May 2011 01:15:01 +0000 Subject: [PATCH] remove trailing white-spaces from unit issue nested set test. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5805 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- test/unit/issue_nested_set_test.rb | 106 ++++++++++++++--------------- 1 file changed, 53 insertions(+), 53 deletions(-) diff --git a/test/unit/issue_nested_set_test.rb b/test/unit/issue_nested_set_test.rb index 46f4dc4dd..6cbc44461 100644 --- a/test/unit/issue_nested_set_test.rb +++ b/test/unit/issue_nested_set_test.rb @@ -1,16 +1,16 @@ -# redMine - project management software -# Copyright (C) 2006-2007 Jean-Philippe Lang +# Redmine - project management software +# Copyright (C) 2006-2011 Jean-Philippe Lang # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. -# +# # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. @@ -21,166 +21,166 @@ class IssueNestedSetTest < ActiveSupport::TestCase fixtures :projects, :users, :members, :member_roles, :roles, :trackers, :projects_trackers, :versions, - :issue_statuses, :issue_categories, :issue_relations, :workflows, + :issue_statuses, :issue_categories, :issue_relations, :workflows, :enumerations, :issues, :custom_fields, :custom_fields_projects, :custom_fields_trackers, :custom_values, :time_entries self.use_transactional_fixtures = false - + def test_create_root_issue issue1 = create_issue! issue2 = create_issue! issue1.reload issue2.reload - + assert_equal [issue1.id, nil, 1, 2], [issue1.root_id, issue1.parent_id, issue1.lft, issue1.rgt] assert_equal [issue2.id, nil, 1, 2], [issue2.root_id, issue2.parent_id, issue2.lft, issue2.rgt] end - + def test_create_child_issue parent = create_issue! child = create_issue!(:parent_issue_id => parent.id) parent.reload child.reload - + assert_equal [parent.id, nil, 1, 4], [parent.root_id, parent.parent_id, parent.lft, parent.rgt] assert_equal [parent.id, parent.id, 2, 3], [child.root_id, child.parent_id, child.lft, child.rgt] end - + def test_creating_a_child_in_different_project_should_not_validate issue = create_issue! child = Issue.new(:project_id => 2, :tracker_id => 1, :author_id => 1, :subject => 'child', :parent_issue_id => issue.id) assert !child.save assert_not_nil child.errors.on(:parent_issue_id) end - + def test_move_a_root_to_child parent1 = create_issue! parent2 = create_issue! child = create_issue!(:parent_issue_id => parent1.id) - + parent2.parent_issue_id = parent1.id parent2.save! child.reload parent1.reload parent2.reload - + assert_equal [parent1.id, 1, 6], [parent1.root_id, parent1.lft, parent1.rgt] assert_equal [parent1.id, 4, 5], [parent2.root_id, parent2.lft, parent2.rgt] assert_equal [parent1.id, 2, 3], [child.root_id, child.lft, child.rgt] end - + def test_move_a_child_to_root parent1 = create_issue! parent2 = create_issue! child = create_issue!(:parent_issue_id => parent1.id) - + child.parent_issue_id = nil child.save! child.reload parent1.reload parent2.reload - + assert_equal [parent1.id, 1, 2], [parent1.root_id, parent1.lft, parent1.rgt] assert_equal [parent2.id, 1, 2], [parent2.root_id, parent2.lft, parent2.rgt] assert_equal [child.id, 1, 2], [child.root_id, child.lft, child.rgt] end - + def test_move_a_child_to_another_issue parent1 = create_issue! parent2 = create_issue! child = create_issue!(:parent_issue_id => parent1.id) - + child.parent_issue_id = parent2.id child.save! child.reload parent1.reload parent2.reload - + assert_equal [parent1.id, 1, 2], [parent1.root_id, parent1.lft, parent1.rgt] assert_equal [parent2.id, 1, 4], [parent2.root_id, parent2.lft, parent2.rgt] assert_equal [parent2.id, 2, 3], [child.root_id, child.lft, child.rgt] end - + def test_move_a_child_with_descendants_to_another_issue parent1 = create_issue! parent2 = create_issue! child = create_issue!(:parent_issue_id => parent1.id) grandchild = create_issue!(:parent_issue_id => child.id) - + parent1.reload parent2.reload child.reload grandchild.reload - + assert_equal [parent1.id, 1, 6], [parent1.root_id, parent1.lft, parent1.rgt] assert_equal [parent2.id, 1, 2], [parent2.root_id, parent2.lft, parent2.rgt] assert_equal [parent1.id, 2, 5], [child.root_id, child.lft, child.rgt] assert_equal [parent1.id, 3, 4], [grandchild.root_id, grandchild.lft, grandchild.rgt] - + child.reload.parent_issue_id = parent2.id child.save! child.reload grandchild.reload parent1.reload parent2.reload - + assert_equal [parent1.id, 1, 2], [parent1.root_id, parent1.lft, parent1.rgt] assert_equal [parent2.id, 1, 6], [parent2.root_id, parent2.lft, parent2.rgt] assert_equal [parent2.id, 2, 5], [child.root_id, child.lft, child.rgt] assert_equal [parent2.id, 3, 4], [grandchild.root_id, grandchild.lft, grandchild.rgt] end - + def test_move_a_child_with_descendants_to_another_project parent1 = create_issue! child = create_issue!(:parent_issue_id => parent1.id) grandchild = create_issue!(:parent_issue_id => child.id) - + assert child.reload.move_to_project(Project.find(2)) child.reload grandchild.reload parent1.reload - + assert_equal [1, parent1.id, 1, 2], [parent1.project_id, parent1.root_id, parent1.lft, parent1.rgt] assert_equal [2, child.id, 1, 4], [child.project_id, child.root_id, child.lft, child.rgt] assert_equal [2, child.id, 2, 3], [grandchild.project_id, grandchild.root_id, grandchild.lft, grandchild.rgt] end - + def test_invalid_move_to_another_project parent1 = create_issue! child = create_issue!(:parent_issue_id => parent1.id) grandchild = create_issue!(:parent_issue_id => child.id, :tracker_id => 2) Project.find(2).tracker_ids = [1] - + parent1.reload assert_equal [1, parent1.id, 1, 6], [parent1.project_id, parent1.root_id, parent1.lft, parent1.rgt] - + # child can not be moved to Project 2 because its child is on a disabled tracker assert_equal false, Issue.find(child.id).move_to_project(Project.find(2)) child.reload grandchild.reload parent1.reload - + # no change assert_equal [1, parent1.id, 1, 6], [parent1.project_id, parent1.root_id, parent1.lft, parent1.rgt] assert_equal [1, parent1.id, 2, 5], [child.project_id, child.root_id, child.lft, child.rgt] assert_equal [1, parent1.id, 3, 4], [grandchild.project_id, grandchild.root_id, grandchild.lft, grandchild.rgt] end - + def test_moving_an_issue_to_a_descendant_should_not_validate parent1 = create_issue! parent2 = create_issue! child = create_issue!(:parent_issue_id => parent1.id) grandchild = create_issue!(:parent_issue_id => child.id) - + child.reload child.parent_issue_id = grandchild.id assert !child.save assert_not_nil child.errors.on(:parent_issue_id) end - + def test_moving_an_issue_should_keep_valid_relations_only issue1 = create_issue! issue2 = create_issue! @@ -196,17 +196,17 @@ class IssueNestedSetTest < ActiveSupport::TestCase assert !IssueRelation.exists?(r2.id) assert IssueRelation.exists?(r3.id) end - + def test_destroy_should_destroy_children issue1 = create_issue! issue2 = create_issue! issue3 = create_issue!(:parent_issue_id => issue2.id) issue4 = create_issue!(:parent_issue_id => issue1.id) - + issue3.init_journal(User.find(2)) issue3.subject = 'child with journal' issue3.save! - + assert_difference 'Issue.count', -2 do assert_difference 'Journal.count', -1 do assert_difference 'JournalDetail.count', -1 do @@ -214,7 +214,7 @@ class IssueNestedSetTest < ActiveSupport::TestCase end end end - + issue1.reload issue4.reload assert !Issue.exists?(issue2.id) @@ -222,17 +222,17 @@ class IssueNestedSetTest < ActiveSupport::TestCase assert_equal [issue1.id, 1, 4], [issue1.root_id, issue1.lft, issue1.rgt] assert_equal [issue1.id, 2, 3], [issue4.root_id, issue4.lft, issue4.rgt] end - + def test_destroy_parent_issue_updated_during_children_destroy parent = create_issue! create_issue!(:start_date => Date.today, :parent_issue_id => parent.id) create_issue!(:start_date => 2.days.from_now, :parent_issue_id => parent.id) - + assert_difference 'Issue.count', -3 do Issue.find(parent.id).destroy end end - + def test_destroy_child_issue_with_children root = Issue.create!(:project_id => 1, :author_id => 2, :tracker_id => 1, :subject => 'root') child = Issue.create!(:project_id => 1, :author_id => 2, :tracker_id => 1, :subject => 'child', :parent_issue_id => root.id) @@ -240,7 +240,7 @@ class IssueNestedSetTest < ActiveSupport::TestCase leaf.init_journal(User.find(2)) leaf.subject = 'leaf with journal' leaf.save! - + assert_difference 'Issue.count', -2 do assert_difference 'Journal.count', -1 do assert_difference 'JournalDetail.count', -1 do @@ -248,11 +248,11 @@ class IssueNestedSetTest < ActiveSupport::TestCase end end end - + root = Issue.find(root.id) assert root.leaf?, "Root issue is not a leaf (lft: #{root.lft}, rgt: #{root.rgt})" end - + def test_parent_priority_should_be_the_highest_child_priority parent = create_issue!(:priority => IssuePriority.find_by_name('Normal')) # Create children @@ -271,7 +271,7 @@ class IssueNestedSetTest < ActiveSupport::TestCase child3.save! assert_equal 'Normal', parent.reload.priority.name end - + def test_parent_dates_should_be_lowest_start_and_highest_due_dates parent = create_issue! create_issue!(:start_date => '2010-01-25', :due_date => '2010-02-15', :parent_issue_id => parent.id) @@ -281,22 +281,22 @@ class IssueNestedSetTest < ActiveSupport::TestCase assert_equal Date.parse('2010-01-25'), parent.start_date assert_equal Date.parse('2010-02-22'), parent.due_date end - + def test_parent_done_ratio_should_be_average_done_ratio_of_leaves parent = create_issue! create_issue!(:done_ratio => 20, :parent_issue_id => parent.id) assert_equal 20, parent.reload.done_ratio create_issue!(:done_ratio => 70, :parent_issue_id => parent.id) assert_equal 45, parent.reload.done_ratio - + child = create_issue!(:done_ratio => 0, :parent_issue_id => parent.id) assert_equal 30, parent.reload.done_ratio - + create_issue!(:done_ratio => 30, :parent_issue_id => child.id) assert_equal 30, child.reload.done_ratio assert_equal 40, parent.reload.done_ratio end - + def test_parent_done_ratio_should_be_weighted_by_estimated_times_if_any parent = create_issue! create_issue!(:estimated_hours => 10, :done_ratio => 20, :parent_issue_id => parent.id) @@ -304,7 +304,7 @@ class IssueNestedSetTest < ActiveSupport::TestCase create_issue!(:estimated_hours => 20, :done_ratio => 50, :parent_issue_id => parent.id) assert_equal (50 * 20 + 20 * 10) / 30, parent.reload.done_ratio end - + def test_parent_estimate_should_be_sum_of_leaves parent = create_issue! create_issue!(:estimated_hours => nil, :parent_issue_id => parent.id) @@ -338,7 +338,7 @@ class IssueNestedSetTest < ActiveSupport::TestCase parent.reload assert_equal [Date.parse('2010-06-02'), Date.parse('2010-06-10')], [parent.start_date, parent.due_date] end - + def test_project_copy_should_copy_issue_tree p = Project.create!(:name => 'Tree copy', :identifier => 'tree-copy', :tracker_ids => [1, 2]) i1 = create_issue!(:project_id => p.id, :subject => 'i1') @@ -349,7 +349,7 @@ class IssueNestedSetTest < ActiveSupport::TestCase c = Project.new(:name => 'Copy', :identifier => 'copy', :tracker_ids => [1, 2]) c.copy(p, :only => 'issues') c.reload - + assert_equal 5, c.issues.count ic1, ic2, ic3, ic4, ic5 = c.issues.find(:all, :order => 'subject') assert ic1.root? @@ -358,7 +358,7 @@ class IssueNestedSetTest < ActiveSupport::TestCase assert_equal ic2, ic4.parent assert ic5.root? end - + # Helper that creates an issue with default attributes def create_issue!(attributes={}) Issue.create!({:project_id => 1, :tracker_id => 1, :author_id => 1, :subject => 'test'}.merge(attributes)) -- 2.39.5