diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2015-05-25 11:37:12 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2015-05-25 11:37:12 +0000 |
commit | 481f70d12537333206199b4a8d2891218959f4ad (patch) | |
tree | 901e580d30bbb87c2f43716574c29483f0dcac16 /test/unit/issue_subtasking_test.rb | |
parent | 4f8bf001302f6e3e4fabe33b86891ec6581e867b (diff) | |
download | redmine-481f70d12537333206199b4a8d2891218959f4ad.tar.gz redmine-481f70d12537333206199b4a8d2891218959f4ad.zip |
Don't store total estimated hours on parent issues (#16092).
Parent can now have its own estimate that is summed up with children estimates.
git-svn-id: http://svn.redmine.org/redmine/trunk@14272 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/unit/issue_subtasking_test.rb')
-rw-r--r-- | test/unit/issue_subtasking_test.rb | 56 |
1 files changed, 42 insertions, 14 deletions
diff --git a/test/unit/issue_subtasking_test.rb b/test/unit/issue_subtasking_test.rb index d9f9a0824..6f00ee948 100644 --- a/test/unit/issue_subtasking_test.rb +++ b/test/unit/issue_subtasking_test.rb @@ -146,23 +146,41 @@ class IssueSubtaskingTest < ActiveSupport::TestCase end def test_done_ratio_of_parent_with_a_child_without_estimated_time_should_not_exceed_100 - parent = Issue.generate! - parent.generate_child!(:estimated_hours => 40) - parent.generate_child!(:estimated_hours => 40) - parent.generate_child!(:estimated_hours => 20) - parent.generate_child! - parent.reload.children.each(&:close!) - assert_equal 100, parent.reload.done_ratio + with_settings :parent_issue_done_ratio => 'derived' do + parent = Issue.generate! + parent.generate_child!(:estimated_hours => 40) + parent.generate_child!(:estimated_hours => 40) + parent.generate_child!(:estimated_hours => 20) + parent.generate_child! + parent.reload.children.each(&:close!) + assert_equal 100, parent.reload.done_ratio + end end def test_done_ratio_of_parent_with_a_child_with_estimated_time_at_0_should_not_exceed_100 - parent = Issue.generate! - parent.generate_child!(:estimated_hours => 40) - parent.generate_child!(:estimated_hours => 40) - parent.generate_child!(:estimated_hours => 20) - parent.generate_child!(:estimated_hours => 0) - parent.reload.children.each(&:close!) - assert_equal 100, parent.reload.done_ratio + with_settings :parent_issue_done_ratio => 'derived' do + parent = Issue.generate! + parent.generate_child!(:estimated_hours => 40) + parent.generate_child!(:estimated_hours => 40) + parent.generate_child!(:estimated_hours => 20) + parent.generate_child!(:estimated_hours => 0) + parent.reload.children.each(&:close!) + assert_equal 100, parent.reload.done_ratio + end + end + + def test_changing_parent_should_update_previous_parent_done_ratio + with_settings :parent_issue_done_ratio => 'derived' do + first_parent = Issue.generate! + second_parent = Issue.generate! + first_parent.generate_child!(:done_ratio => 40) + child = first_parent.generate_child!(:done_ratio => 20) + assert_equal 30, first_parent.reload.done_ratio + assert_equal 0, second_parent.reload.done_ratio + child.update_attributes(:parent_issue_id => second_parent.id) + assert_equal 40, first_parent.reload.done_ratio + assert_equal 20, second_parent.reload.done_ratio + end end def test_parent_dates_should_be_editable_with_parent_issue_dates_set_to_independent @@ -227,4 +245,14 @@ class IssueSubtaskingTest < ActiveSupport::TestCase assert_equal 0, parent.reload.done_ratio end end + + def test_parent_total_estimated_hours_should_be_sum_of_descendants + parent = Issue.generate! + parent.generate_child!(:estimated_hours => nil) + assert_equal 0, parent.reload.total_estimated_hours + parent.generate_child!(:estimated_hours => 5) + assert_equal 5, parent.reload.total_estimated_hours + parent.generate_child!(:estimated_hours => 7) + assert_equal 12, parent.reload.total_estimated_hours + end end |