diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2010-04-11 13:20:02 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2010-04-11 13:20:02 +0000 |
commit | 71a4158fd0494e47e52ec701f7d40f5ae068f811 (patch) | |
tree | 6211d9b4bd6524f678f33429300771d6e0cc813a /test/unit/version_test.rb | |
parent | 58792737394c59ecac08db2cea0eeebb836f160a (diff) | |
download | redmine-71a4158fd0494e47e52ec701f7d40f5ae068f811.tar.gz redmine-71a4158fd0494e47e52ec701f7d40f5ae068f811.zip |
Fixes calculation of version estimated hours with subtasks (#5265).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3633 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/unit/version_test.rb')
-rw-r--r-- | test/unit/version_test.rb | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/test/unit/version_test.rb b/test/unit/version_test.rb index dcc1edbc8..1abb4a272 100644 --- a/test/unit/version_test.rb +++ b/test/unit/version_test.rb @@ -104,6 +104,34 @@ class VersionTest < ActiveSupport::TestCase assert_progress_equal (25.0*0.2 + 25.0*1 + 10.0*0.3 + 40.0*0.1)/100.0*100, v.completed_pourcent assert_progress_equal 25.0/100.0*100, v.closed_pourcent end + + context "#estimated_hours" do + setup do + @version = Version.create!(:project_id => 1, :name => '#estimated_hours') + end + + should "return 0 with no assigned issues" do + assert_equal 0, @version.estimated_hours + end + + should "return 0 with no estimated hours" do + add_issue(@version) + assert_equal 0, @version.estimated_hours + end + + should "return the sum of estimated hours" do + add_issue(@version, :estimated_hours => 2.5) + add_issue(@version, :estimated_hours => 5) + assert_equal 7.5, @version.estimated_hours + end + + should "return the sum of leaves estimated hours" do + parent = add_issue(@version) + add_issue(@version, :estimated_hours => 2.5, :parent_issue_id => parent.id) + add_issue(@version, :estimated_hours => 5, :parent_issue_id => parent.id) + assert_equal 7.5, @version.estimated_hours + end + end test "should update all issue's fixed_version associations in case the hierarchy changed XXX" do User.current = User.find(1) # Need the admin's permissions |