Mercurial > hg > soundsoftware-site
comparison test/unit/version_test.rb @ 22:40f7cfd4df19
* Update to SVN trunk rev 4173
author | Chris Cannam <chris.cannam@soundsoftware.ac.uk> |
---|---|
date | Fri, 24 Sep 2010 14:06:04 +0100 |
parents | 513646585e45 |
children | af80e5618e9b 8661b858af72 |
comparison
equal
deleted
inserted
replaced
14:1d32c0a0efbf | 22:40f7cfd4df19 |
---|---|
102 add_issue(v, :estimated_hours => 10, :done_ratio => 30) | 102 add_issue(v, :estimated_hours => 10, :done_ratio => 30) |
103 add_issue(v, :estimated_hours => 40, :done_ratio => 10) | 103 add_issue(v, :estimated_hours => 40, :done_ratio => 10) |
104 assert_progress_equal (25.0*0.2 + 25.0*1 + 10.0*0.3 + 40.0*0.1)/100.0*100, v.completed_pourcent | 104 assert_progress_equal (25.0*0.2 + 25.0*1 + 10.0*0.3 + 40.0*0.1)/100.0*100, v.completed_pourcent |
105 assert_progress_equal 25.0/100.0*100, v.closed_pourcent | 105 assert_progress_equal 25.0/100.0*100, v.closed_pourcent |
106 end | 106 end |
107 | 107 |
108 context "#behind_schedule?" do | |
109 setup do | |
110 ProjectCustomField.destroy_all # Custom values are a mess to isolate in tests | |
111 @project = Project.generate!(:identifier => 'test0') | |
112 @project.trackers << Tracker.generate! | |
113 | |
114 @version = Version.generate!(:project => @project, :effective_date => nil) | |
115 end | |
116 | |
117 should "be false if there are no issues assigned" do | |
118 @version.update_attribute(:effective_date, Date.yesterday) | |
119 assert_equal false, @version.behind_schedule? | |
120 end | |
121 | |
122 should "be false if there is no effective_date" do | |
123 assert_equal false, @version.behind_schedule? | |
124 end | |
125 | |
126 should "be false if all of the issues are ahead of schedule" do | |
127 @version.update_attribute(:effective_date, 7.days.from_now.to_date) | |
128 @version.fixed_issues = [ | |
129 Issue.generate_for_project!(@project, :start_date => 7.days.ago, :done_ratio => 60), # 14 day span, 60% done, 50% time left | |
130 Issue.generate_for_project!(@project, :start_date => 7.days.ago, :done_ratio => 60) # 14 day span, 60% done, 50% time left | |
131 ] | |
132 assert_equal 60, @version.completed_pourcent | |
133 assert_equal false, @version.behind_schedule? | |
134 end | |
135 | |
136 should "be true if any of the issues are behind schedule" do | |
137 @version.update_attribute(:effective_date, 7.days.from_now.to_date) | |
138 @version.fixed_issues = [ | |
139 Issue.generate_for_project!(@project, :start_date => 7.days.ago, :done_ratio => 60), # 14 day span, 60% done, 50% time left | |
140 Issue.generate_for_project!(@project, :start_date => 7.days.ago, :done_ratio => 20) # 14 day span, 20% done, 50% time left | |
141 ] | |
142 assert_equal 40, @version.completed_pourcent | |
143 assert_equal true, @version.behind_schedule? | |
144 end | |
145 | |
146 should "be false if all of the issues are complete" do | |
147 @version.update_attribute(:effective_date, 7.days.from_now.to_date) | |
148 @version.fixed_issues = [ | |
149 Issue.generate_for_project!(@project, :start_date => 14.days.ago, :done_ratio => 100, :status => IssueStatus.find(5)), # 7 day span | |
150 Issue.generate_for_project!(@project, :start_date => 14.days.ago, :done_ratio => 100, :status => IssueStatus.find(5)) # 7 day span | |
151 ] | |
152 assert_equal 100, @version.completed_pourcent | |
153 assert_equal false, @version.behind_schedule? | |
154 | |
155 end | |
156 end | |
157 | |
108 context "#estimated_hours" do | 158 context "#estimated_hours" do |
109 setup do | 159 setup do |
110 @version = Version.create!(:project_id => 1, :name => '#estimated_hours') | 160 @version = Version.create!(:project_id => 1, :name => '#estimated_hours') |
111 end | 161 end |
112 | 162 |