Mercurial > hg > soundsoftware-site
diff test/unit/version_test.rb @ 1298:4f746d8966dd redmine_2.3_integration
Merge from redmine-2.3 branch to create new branch redmine-2.3-integration
author | Chris Cannam |
---|---|
date | Fri, 14 Jun 2013 09:28:30 +0100 |
parents | bb32da3bea34 622f24f53b42 |
children |
line wrap: on
line diff
--- a/test/unit/version_test.rb Fri Jun 14 09:07:32 2013 +0100 +++ b/test/unit/version_test.rb Fri Jun 14 09:28:30 2013 +0100 @@ -1,5 +1,5 @@ # Redmine - project management software -# Copyright (C) 2006-2012 Jean-Philippe Lang +# Copyright (C) 2006-2013 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 @@ -37,6 +37,8 @@ assert !v.valid? v.effective_date = '2012-31-11' assert !v.valid? + v.effective_date = '-2012-31-11' + assert !v.valid? v.effective_date = 'ABC' assert !v.valid? assert_include I18n.translate('activerecord.errors.messages.not_a_date'), @@ -46,8 +48,8 @@ def test_progress_should_be_0_with_no_assigned_issues project = Project.find(1) v = Version.create!(:project => project, :name => 'Progress') - assert_equal 0, v.completed_pourcent - assert_equal 0, v.closed_pourcent + assert_equal 0, v.completed_percent + assert_equal 0, v.closed_percent end def test_progress_should_be_0_with_unbegun_assigned_issues @@ -55,20 +57,20 @@ v = Version.create!(:project => project, :name => 'Progress') add_issue(v) add_issue(v, :done_ratio => 0) - assert_progress_equal 0, v.completed_pourcent - assert_progress_equal 0, v.closed_pourcent + assert_progress_equal 0, v.completed_percent + assert_progress_equal 0, v.closed_percent end def test_progress_should_be_100_with_closed_assigned_issues project = Project.find(1) - status = IssueStatus.find(:first, :conditions => {:is_closed => true}) + status = IssueStatus.where(:is_closed => true).first v = Version.create!(:project => project, :name => 'Progress') add_issue(v, :status => status) add_issue(v, :status => status, :done_ratio => 20) add_issue(v, :status => status, :done_ratio => 70, :estimated_hours => 25) add_issue(v, :status => status, :estimated_hours => 15) - assert_progress_equal 100.0, v.completed_pourcent - assert_progress_equal 100.0, v.closed_pourcent + assert_progress_equal 100.0, v.completed_percent + assert_progress_equal 100.0, v.closed_percent end def test_progress_should_consider_done_ratio_of_open_assigned_issues @@ -77,8 +79,8 @@ add_issue(v) add_issue(v, :done_ratio => 20) add_issue(v, :done_ratio => 70) - assert_progress_equal (0.0 + 20.0 + 70.0)/3, v.completed_pourcent - assert_progress_equal 0, v.closed_pourcent + assert_progress_equal (0.0 + 20.0 + 70.0)/3, v.completed_percent + assert_progress_equal 0, v.closed_percent end def test_progress_should_consider_closed_issues_as_completed @@ -86,9 +88,9 @@ v = Version.create!(:project => project, :name => 'Progress') add_issue(v) add_issue(v, :done_ratio => 20) - add_issue(v, :status => IssueStatus.find(:first, :conditions => {:is_closed => true})) - assert_progress_equal (0.0 + 20.0 + 100.0)/3, v.completed_pourcent - assert_progress_equal (100.0)/3, v.closed_pourcent + add_issue(v, :status => IssueStatus.where(:is_closed => true).first) + assert_progress_equal (0.0 + 20.0 + 100.0)/3, v.completed_percent + assert_progress_equal (100.0)/3, v.closed_percent end def test_progress_should_consider_estimated_hours_to_weigth_issues @@ -97,20 +99,20 @@ add_issue(v, :estimated_hours => 10) add_issue(v, :estimated_hours => 20, :done_ratio => 30) add_issue(v, :estimated_hours => 40, :done_ratio => 10) - add_issue(v, :estimated_hours => 25, :status => IssueStatus.find(:first, :conditions => {:is_closed => true})) - assert_progress_equal (10.0*0 + 20.0*0.3 + 40*0.1 + 25.0*1)/95.0*100, v.completed_pourcent - assert_progress_equal 25.0/95.0*100, v.closed_pourcent + add_issue(v, :estimated_hours => 25, :status => IssueStatus.where(:is_closed => true).first) + assert_progress_equal (10.0*0 + 20.0*0.3 + 40*0.1 + 25.0*1)/95.0*100, v.completed_percent + assert_progress_equal 25.0/95.0*100, v.closed_percent end def test_progress_should_consider_average_estimated_hours_to_weigth_unestimated_issues project = Project.find(1) v = Version.create!(:project => project, :name => 'Progress') add_issue(v, :done_ratio => 20) - add_issue(v, :status => IssueStatus.find(:first, :conditions => {:is_closed => true})) + add_issue(v, :status => IssueStatus.where(:is_closed => true).first) add_issue(v, :estimated_hours => 10, :done_ratio => 30) add_issue(v, :estimated_hours => 40, :done_ratio => 10) - 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 + assert_progress_equal (25.0*0.2 + 25.0*1 + 10.0*0.3 + 40.0*0.1)/100.0*100, v.completed_percent + assert_progress_equal 25.0/100.0*100, v.closed_percent end def test_should_sort_scheduled_then_unscheduled_versions @@ -152,7 +154,7 @@ @version.update_attribute(:effective_date, 7.days.from_now.to_date) add_issue(@version, :start_date => 7.days.ago, :done_ratio => 60) # 14 day span, 60% done, 50% time left add_issue(@version, :start_date => 7.days.ago, :done_ratio => 60) # 14 day span, 60% done, 50% time left - assert_equal 60, @version.completed_pourcent + assert_equal 60, @version.completed_percent assert_equal false, @version.behind_schedule? end @@ -160,7 +162,7 @@ @version.update_attribute(:effective_date, 7.days.from_now.to_date) add_issue(@version, :start_date => 7.days.ago, :done_ratio => 60) # 14 day span, 60% done, 50% time left add_issue(@version, :start_date => 7.days.ago, :done_ratio => 20) # 14 day span, 20% done, 50% time left - assert_equal 40, @version.completed_pourcent + assert_equal 40, @version.completed_percent assert_equal true, @version.behind_schedule? end @@ -168,7 +170,7 @@ @version.update_attribute(:effective_date, 7.days.from_now.to_date) add_issue(@version, :start_date => 14.days.ago, :done_ratio => 100, :status => IssueStatus.find(5)) # 7 day span add_issue(@version, :start_date => 14.days.ago, :done_ratio => 100, :status => IssueStatus.find(5)) # 7 day span - assert_equal 100, @version.completed_pourcent + assert_equal 100, @version.completed_percent assert_equal false, @version.behind_schedule? end end @@ -242,8 +244,8 @@ Issue.create!({:project => version.project, :fixed_version => version, :subject => 'Test', - :author => User.find(:first), - :tracker => version.project.trackers.find(:first)}.merge(attributes)) + :author => User.first, + :tracker => version.project.trackers.first}.merge(attributes)) end def assert_progress_equal(expected_float, actual_float, message="")