@@ -1,779 +1,758 | |||
|
1 | 1 | # Redmine - project management software |
|
2 | 2 | # Copyright (C) 2006-2011 Jean-Philippe Lang |
|
3 | 3 | # |
|
4 | 4 | # This program is free software; you can redistribute it and/or |
|
5 | 5 | # modify it under the terms of the GNU General Public License |
|
6 | 6 | # as published by the Free Software Foundation; either version 2 |
|
7 | 7 | # of the License, or (at your option) any later version. |
|
8 | 8 | # |
|
9 | 9 | # This program is distributed in the hope that it will be useful, |
|
10 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | 12 | # GNU General Public License for more details. |
|
13 | 13 | # |
|
14 | 14 | # You should have received a copy of the GNU General Public License |
|
15 | 15 | # along with this program; if not, write to the Free Software |
|
16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
17 | 17 | |
|
18 | 18 | require File.expand_path('../../../../../test_helper', __FILE__) |
|
19 | 19 | |
|
20 |
class Redmine::Helpers::GanttTest < Acti |
|
|
21 | # Utility methods and classes so assert_select can be used. | |
|
22 | class GanttViewTest < ActionView::Base | |
|
23 | include ActionView::Helpers::UrlHelper | |
|
24 | include ActionView::Helpers::TextHelper | |
|
25 | include ActionController::UrlWriter | |
|
20 | class Redmine::Helpers::GanttHelperTest < ActionView::TestCase | |
|
26 | 21 |
|
|
27 | 22 |
|
|
28 | 23 |
|
|
29 | 24 | |
|
30 | def self.default_url_options | |
|
31 | {:only_path => true } | |
|
32 | end | |
|
33 | ||
|
34 | end | |
|
35 | ||
|
36 | include ActionController::Assertions::SelectorAssertions | |
|
37 | ||
|
38 | 25 | def setup |
|
39 | @response = ActionController::TestResponse.new | |
|
26 | setup_with_controller | |
|
40 | 27 | # Fixtures |
|
41 | 28 | ProjectCustomField.delete_all |
|
42 | 29 | Project.destroy_all |
|
43 | 30 | |
|
44 | 31 | User.current = User.find(1) |
|
45 | 32 | end |
|
46 | 33 | |
|
47 | def build_view | |
|
48 | @view = GanttViewTest.new | |
|
49 | end | |
|
50 | ||
|
51 | def html_document | |
|
52 | HTML::Document.new(@response.body) | |
|
53 | end | |
|
54 | ||
|
55 | 34 | # Creates a Gantt chart for a 4 week span |
|
56 | 35 | def create_gantt(project=Project.generate!, options={}) |
|
57 | 36 | @project = project |
|
58 | 37 | @gantt = Redmine::Helpers::Gantt.new(options) |
|
59 | 38 | @gantt.project = @project |
|
60 | 39 | @gantt.query = Query.generate_default!(:project => @project) |
|
61 |
@gantt.view = |
|
|
40 | @gantt.view = self | |
|
62 | 41 | @gantt.instance_variable_set('@date_from', options[:date_from] || 2.weeks.ago.to_date) |
|
63 | 42 | @gantt.instance_variable_set('@date_to', options[:date_to] || 2.weeks.from_now.to_date) |
|
64 | 43 | end |
|
65 | 44 | |
|
66 | 45 | context "#number_of_rows" do |
|
67 | 46 | |
|
68 | 47 | context "with one project" do |
|
69 | 48 | should "return the number of rows just for that project" |
|
70 | 49 | end |
|
71 | 50 | |
|
72 | 51 | context "with no project" do |
|
73 | 52 | should "return the total number of rows for all the projects, resursively" |
|
74 | 53 | end |
|
75 | 54 | |
|
76 | 55 | should "not exceed max_rows option" do |
|
77 | 56 | p = Project.generate! |
|
78 | 57 | 5.times do |
|
79 | 58 | Issue.generate_for_project!(p) |
|
80 | 59 | end |
|
81 | 60 | |
|
82 | 61 | create_gantt(p) |
|
83 | 62 | @gantt.render |
|
84 | 63 | assert_equal 6, @gantt.number_of_rows |
|
85 | 64 | assert !@gantt.truncated |
|
86 | 65 | |
|
87 | 66 | create_gantt(p, :max_rows => 3) |
|
88 | 67 | @gantt.render |
|
89 | 68 | assert_equal 3, @gantt.number_of_rows |
|
90 | 69 | assert @gantt.truncated |
|
91 | 70 | end |
|
92 | 71 | end |
|
93 | 72 | |
|
94 | 73 | context "#number_of_rows_on_project" do |
|
95 | 74 | setup do |
|
96 | 75 | create_gantt |
|
97 | 76 | end |
|
98 | 77 | |
|
99 | 78 | should "count 0 for an empty the project" do |
|
100 | 79 | assert_equal 0, @gantt.number_of_rows_on_project(@project) |
|
101 | 80 | end |
|
102 | 81 | |
|
103 | 82 | should "count the number of issues without a version" do |
|
104 | 83 | @project.issues << Issue.generate_for_project!(@project, :fixed_version => nil) |
|
105 | 84 | assert_equal 2, @gantt.number_of_rows_on_project(@project) |
|
106 | 85 | end |
|
107 | 86 | |
|
108 | 87 | should "count the number of issues on versions, including cross-project" do |
|
109 | 88 | version = Version.generate! |
|
110 | 89 | @project.versions << version |
|
111 | 90 | @project.issues << Issue.generate_for_project!(@project, :fixed_version => version) |
|
112 | 91 | |
|
113 | 92 | assert_equal 3, @gantt.number_of_rows_on_project(@project) |
|
114 | 93 | end |
|
115 | 94 | end |
|
116 | 95 | |
|
117 | 96 | # TODO: more of an integration test |
|
118 | 97 | context "#subjects" do |
|
119 | 98 | setup do |
|
120 | 99 | create_gantt |
|
121 | 100 | @project.enabled_module_names = [:issue_tracking] |
|
122 | 101 | @tracker = Tracker.generate! |
|
123 | 102 | @project.trackers << @tracker |
|
124 | 103 | @version = Version.generate!(:effective_date => 1.week.from_now.to_date, :sharing => 'none') |
|
125 | 104 | @project.versions << @version |
|
126 | 105 | |
|
127 | 106 | @issue = Issue.generate!(:fixed_version => @version, |
|
128 | 107 | :subject => "gantt#line_for_project", |
|
129 | 108 | :tracker => @tracker, |
|
130 | 109 | :project => @project, |
|
131 | 110 | :done_ratio => 30, |
|
132 | 111 | :start_date => Date.yesterday, |
|
133 | 112 | :due_date => 1.week.from_now.to_date) |
|
134 | 113 | @project.issues << @issue |
|
135 | 114 | end |
|
136 | 115 | |
|
137 | 116 | context "project" do |
|
138 | 117 | should "be rendered" do |
|
139 |
@ |
|
|
118 | @output_buffer = @gantt.subjects | |
|
140 | 119 | assert_select "div.project-name a", /#{@project.name}/ |
|
141 | 120 | end |
|
142 | 121 | |
|
143 | 122 | should "have an indent of 4" do |
|
144 |
@ |
|
|
123 | @output_buffer = @gantt.subjects | |
|
145 | 124 | assert_select "div.project-name[style*=left:4px]" |
|
146 | 125 | end |
|
147 | 126 | end |
|
148 | 127 | |
|
149 | 128 | context "version" do |
|
150 | 129 | should "be rendered" do |
|
151 |
@ |
|
|
130 | @output_buffer = @gantt.subjects | |
|
152 | 131 | assert_select "div.version-name a", /#{@version.name}/ |
|
153 | 132 | end |
|
154 | 133 | |
|
155 | 134 | should "be indented 24 (one level)" do |
|
156 |
@ |
|
|
135 | @output_buffer = @gantt.subjects | |
|
157 | 136 | assert_select "div.version-name[style*=left:24px]" |
|
158 | 137 | end |
|
159 | 138 | |
|
160 | 139 | context "without assigned issues" do |
|
161 | 140 | setup do |
|
162 | 141 | @version = Version.generate!(:effective_date => 2.week.from_now.to_date, :sharing => 'none', :name => 'empty_version') |
|
163 | 142 | @project.versions << @version |
|
164 | 143 | end |
|
165 | 144 | |
|
166 | 145 | should "not be rendered" do |
|
167 |
@ |
|
|
146 | @output_buffer = @gantt.subjects | |
|
168 | 147 | assert_select "div.version-name a", :text => /#{@version.name}/, :count => 0 |
|
169 | 148 | end |
|
170 | 149 | end |
|
171 | 150 | end |
|
172 | 151 | |
|
173 | 152 | context "issue" do |
|
174 | 153 | should "be rendered" do |
|
175 |
@ |
|
|
154 | @output_buffer = @gantt.subjects | |
|
176 | 155 | assert_select "div.issue-subject", /#{@issue.subject}/ |
|
177 | 156 | end |
|
178 | 157 | |
|
179 | 158 | should "be indented 44 (two levels)" do |
|
180 |
@ |
|
|
159 | @output_buffer = @gantt.subjects | |
|
181 | 160 | assert_select "div.issue-subject[style*=left:44px]" |
|
182 | 161 | end |
|
183 | 162 | |
|
184 | 163 | context "assigned to a shared version of another project" do |
|
185 | 164 | setup do |
|
186 | 165 | p = Project.generate! |
|
187 | 166 | p.trackers << @tracker |
|
188 | 167 | p.enabled_module_names = [:issue_tracking] |
|
189 | 168 | @shared_version = Version.generate!(:sharing => 'system') |
|
190 | 169 | p.versions << @shared_version |
|
191 | 170 | # Reassign the issue to a shared version of another project |
|
192 | 171 | |
|
193 | 172 | @issue = Issue.generate!(:fixed_version => @shared_version, |
|
194 | 173 | :subject => "gantt#assigned_to_shared_version", |
|
195 | 174 | :tracker => @tracker, |
|
196 | 175 | :project => @project, |
|
197 | 176 | :done_ratio => 30, |
|
198 | 177 | :start_date => Date.yesterday, |
|
199 | 178 | :due_date => 1.week.from_now.to_date) |
|
200 | 179 | @project.issues << @issue |
|
201 | 180 | end |
|
202 | 181 | |
|
203 | 182 | should "be rendered" do |
|
204 |
@ |
|
|
183 | @output_buffer = @gantt.subjects | |
|
205 | 184 | assert_select "div.issue-subject", /#{@issue.subject}/ |
|
206 | 185 | end |
|
207 | 186 | end |
|
208 | 187 | |
|
209 | 188 | context "with subtasks" do |
|
210 | 189 | setup do |
|
211 | 190 | attrs = {:project => @project, :tracker => @tracker, :fixed_version => @version} |
|
212 | 191 | @child1 = Issue.generate!(attrs.merge(:subject => 'child1', :parent_issue_id => @issue.id, :start_date => Date.yesterday, :due_date => 2.day.from_now.to_date)) |
|
213 | 192 | @child2 = Issue.generate!(attrs.merge(:subject => 'child2', :parent_issue_id => @issue.id, :start_date => Date.today, :due_date => 1.week.from_now.to_date)) |
|
214 | 193 | @grandchild = Issue.generate!(attrs.merge(:subject => 'grandchild', :parent_issue_id => @child1.id, :start_date => Date.yesterday, :due_date => 2.day.from_now.to_date)) |
|
215 | 194 | end |
|
216 | 195 | |
|
217 | 196 | should "indent subtasks" do |
|
218 |
@ |
|
|
197 | @output_buffer = @gantt.subjects | |
|
219 | 198 | # parent task 44px |
|
220 | 199 | assert_select "div.issue-subject[style*=left:44px]", /#{@issue.subject}/ |
|
221 | 200 | # children 64px |
|
222 | 201 | assert_select "div.issue-subject[style*=left:64px]", /child1/ |
|
223 | 202 | assert_select "div.issue-subject[style*=left:64px]", /child2/ |
|
224 | 203 | # grandchild 84px |
|
225 |
assert_select "div.issue-subject[style*=left:84px]", /grandchild/, @ |
|
|
204 | assert_select "div.issue-subject[style*=left:84px]", /grandchild/, @output_buffer | |
|
226 | 205 | end |
|
227 | 206 | end |
|
228 | 207 | end |
|
229 | 208 | end |
|
230 | 209 | |
|
231 | 210 | context "#lines" do |
|
232 | 211 | setup do |
|
233 | 212 | create_gantt |
|
234 | 213 | @project.enabled_module_names = [:issue_tracking] |
|
235 | 214 | @tracker = Tracker.generate! |
|
236 | 215 | @project.trackers << @tracker |
|
237 | 216 | @version = Version.generate!(:effective_date => 1.week.from_now.to_date) |
|
238 | 217 | @project.versions << @version |
|
239 | 218 | @issue = Issue.generate!(:fixed_version => @version, |
|
240 | 219 | :subject => "gantt#line_for_project", |
|
241 | 220 | :tracker => @tracker, |
|
242 | 221 | :project => @project, |
|
243 | 222 | :done_ratio => 30, |
|
244 | 223 | :start_date => Date.yesterday, |
|
245 | 224 | :due_date => 1.week.from_now.to_date) |
|
246 | 225 | @project.issues << @issue |
|
247 | 226 | |
|
248 |
@ |
|
|
227 | @output_buffer = @gantt.lines | |
|
249 | 228 | end |
|
250 | 229 | |
|
251 | 230 | context "project" do |
|
252 | 231 | should "be rendered" do |
|
253 | 232 | assert_select "div.project.task_todo" |
|
254 | 233 | assert_select "div.project.starting" |
|
255 | 234 | assert_select "div.project.ending" |
|
256 | 235 | assert_select "div.label.project", /#{@project.name}/ |
|
257 | 236 | end |
|
258 | 237 | end |
|
259 | 238 | |
|
260 | 239 | context "version" do |
|
261 | 240 | should "be rendered" do |
|
262 | 241 | assert_select "div.version.task_todo" |
|
263 | 242 | assert_select "div.version.starting" |
|
264 | 243 | assert_select "div.version.ending" |
|
265 | 244 | assert_select "div.label.version", /#{@version.name}/ |
|
266 | 245 | end |
|
267 | 246 | end |
|
268 | 247 | |
|
269 | 248 | context "issue" do |
|
270 | 249 | should "be rendered" do |
|
271 | 250 | assert_select "div.task_todo" |
|
272 | 251 | assert_select "div.task.label", /#{@issue.done_ratio}/ |
|
273 | 252 | assert_select "div.tooltip", /#{@issue.subject}/ |
|
274 | 253 | end |
|
275 | 254 | end |
|
276 | 255 | end |
|
277 | 256 | |
|
278 | 257 | context "#render_project" do |
|
279 | 258 | should "be tested" |
|
280 | 259 | end |
|
281 | 260 | |
|
282 | 261 | context "#render_issues" do |
|
283 | 262 | should "be tested" |
|
284 | 263 | end |
|
285 | 264 | |
|
286 | 265 | context "#render_version" do |
|
287 | 266 | should "be tested" |
|
288 | 267 | end |
|
289 | 268 | |
|
290 | 269 | context "#subject_for_project" do |
|
291 | 270 | setup do |
|
292 | 271 | create_gantt |
|
293 | 272 | end |
|
294 | 273 | |
|
295 | 274 | context ":html format" do |
|
296 | 275 | should "add an absolute positioned div" do |
|
297 |
@ |
|
|
276 | @output_buffer = @gantt.subject_for_project(@project, {:format => :html}) | |
|
298 | 277 | assert_select "div[style*=absolute]" |
|
299 | 278 | end |
|
300 | 279 | |
|
301 | 280 | should "use the indent option to move the div to the right" do |
|
302 |
@ |
|
|
281 | @output_buffer = @gantt.subject_for_project(@project, {:format => :html, :indent => 40}) | |
|
303 | 282 | assert_select "div[style*=left:40]" |
|
304 | 283 | end |
|
305 | 284 | |
|
306 | 285 | should "include the project name" do |
|
307 |
@ |
|
|
286 | @output_buffer = @gantt.subject_for_project(@project, {:format => :html}) | |
|
308 | 287 | assert_select 'div', :text => /#{@project.name}/ |
|
309 | 288 | end |
|
310 | 289 | |
|
311 | 290 | should "include a link to the project" do |
|
312 |
@ |
|
|
291 | @output_buffer = @gantt.subject_for_project(@project, {:format => :html}) | |
|
313 | 292 | assert_select 'a[href=?]', "/projects/#{@project.identifier}", :text => /#{@project.name}/ |
|
314 | 293 | end |
|
315 | 294 | |
|
316 | 295 | should "style overdue projects" do |
|
317 | 296 | @project.enabled_module_names = [:issue_tracking] |
|
318 | 297 | @project.versions << Version.generate!(:effective_date => Date.yesterday) |
|
319 | 298 | |
|
320 | 299 | assert @project.overdue?, "Need an overdue project for this test" |
|
321 |
@ |
|
|
300 | @output_buffer = @gantt.subject_for_project(@project, {:format => :html}) | |
|
322 | 301 | |
|
323 | 302 | assert_select 'div span.project-overdue' |
|
324 | 303 | end |
|
325 | 304 | |
|
326 | 305 | |
|
327 | 306 | end |
|
328 | 307 | |
|
329 | 308 | should "test the PNG format" |
|
330 | 309 | should "test the PDF format" |
|
331 | 310 | end |
|
332 | 311 | |
|
333 | 312 | context "#line_for_project" do |
|
334 | 313 | setup do |
|
335 | 314 | create_gantt |
|
336 | 315 | @project.enabled_module_names = [:issue_tracking] |
|
337 | 316 | @tracker = Tracker.generate! |
|
338 | 317 | @project.trackers << @tracker |
|
339 | 318 | @version = Version.generate!(:effective_date => Date.yesterday) |
|
340 | 319 | @project.versions << @version |
|
341 | 320 | |
|
342 | 321 | @project.issues << Issue.generate!(:fixed_version => @version, |
|
343 | 322 | :subject => "gantt#line_for_project", |
|
344 | 323 | :tracker => @tracker, |
|
345 | 324 | :project => @project, |
|
346 | 325 | :done_ratio => 30, |
|
347 | 326 | :start_date => 1.week.ago.to_date, |
|
348 | 327 | :due_date => 1.week.from_now.to_date) |
|
349 | 328 | end |
|
350 | 329 | |
|
351 | 330 | context ":html format" do |
|
352 | 331 | context "todo line" do |
|
353 | 332 | should "start from the starting point on the left" do |
|
354 |
@ |
|
|
355 |
assert_select "div.project.task_todo[style*=left:28px]", true, @ |
|
|
333 | @output_buffer = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) | |
|
334 | assert_select "div.project.task_todo[style*=left:28px]", true, @output_buffer | |
|
356 | 335 | end |
|
357 | 336 | |
|
358 | 337 | should "be the total width of the project" do |
|
359 |
@ |
|
|
360 |
assert_select "div.project.task_todo[style*=width:58px]", true, @ |
|
|
338 | @output_buffer = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) | |
|
339 | assert_select "div.project.task_todo[style*=width:58px]", true, @output_buffer | |
|
361 | 340 | end |
|
362 | 341 | |
|
363 | 342 | end |
|
364 | 343 | |
|
365 | 344 | context "late line" do |
|
366 | 345 | should_eventually "start from the starting point on the left" do |
|
367 |
@ |
|
|
368 |
assert_select "div.project.task_late[style*=left:28px]", true, @ |
|
|
346 | @output_buffer = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) | |
|
347 | assert_select "div.project.task_late[style*=left:28px]", true, @output_buffer | |
|
369 | 348 | end |
|
370 | 349 | |
|
371 | 350 | should_eventually "be the total delayed width of the project" do |
|
372 |
@ |
|
|
373 |
assert_select "div.project.task_late[style*=width:30px]", true, @ |
|
|
351 | @output_buffer = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) | |
|
352 | assert_select "div.project.task_late[style*=width:30px]", true, @output_buffer | |
|
374 | 353 | end |
|
375 | 354 | end |
|
376 | 355 | |
|
377 | 356 | context "done line" do |
|
378 | 357 | should_eventually "start from the starting point on the left" do |
|
379 |
@ |
|
|
380 |
assert_select "div.project.task_done[style*=left:28px]", true, @ |
|
|
358 | @output_buffer = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) | |
|
359 | assert_select "div.project.task_done[style*=left:28px]", true, @output_buffer | |
|
381 | 360 | end |
|
382 | 361 | |
|
383 | 362 | should_eventually "Be the total done width of the project" do |
|
384 |
@ |
|
|
385 |
assert_select "div.project.task_done[style*=width:18px]", true, @ |
|
|
363 | @output_buffer = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) | |
|
364 | assert_select "div.project.task_done[style*=width:18px]", true, @output_buffer | |
|
386 | 365 | end |
|
387 | 366 | end |
|
388 | 367 | |
|
389 | 368 | context "starting marker" do |
|
390 | 369 | should "not appear if the starting point is off the gantt chart" do |
|
391 | 370 | # Shift the date range of the chart |
|
392 | 371 | @gantt.instance_variable_set('@date_from', Date.today) |
|
393 | 372 | |
|
394 |
@ |
|
|
395 |
assert_select "div.project.starting", false, @ |
|
|
373 | @output_buffer = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) | |
|
374 | assert_select "div.project.starting", false, @output_buffer | |
|
396 | 375 | end |
|
397 | 376 | |
|
398 | 377 | should "appear at the starting point" do |
|
399 |
@ |
|
|
400 |
assert_select "div.project.starting[style*=left:28px]", true, @ |
|
|
378 | @output_buffer = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) | |
|
379 | assert_select "div.project.starting[style*=left:28px]", true, @output_buffer | |
|
401 | 380 | end |
|
402 | 381 | end |
|
403 | 382 | |
|
404 | 383 | context "ending marker" do |
|
405 | 384 | should "not appear if the starting point is off the gantt chart" do |
|
406 | 385 | # Shift the date range of the chart |
|
407 | 386 | @gantt.instance_variable_set('@date_to', 2.weeks.ago.to_date) |
|
408 | 387 | |
|
409 |
@ |
|
|
410 |
assert_select "div.project.ending", false, @ |
|
|
388 | @output_buffer = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) | |
|
389 | assert_select "div.project.ending", false, @output_buffer | |
|
411 | 390 | |
|
412 | 391 | end |
|
413 | 392 | |
|
414 | 393 | should "appear at the end of the date range" do |
|
415 |
@ |
|
|
416 |
assert_select "div.project.ending[style*=left:88px]", true, @ |
|
|
394 | @output_buffer = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) | |
|
395 | assert_select "div.project.ending[style*=left:88px]", true, @output_buffer | |
|
417 | 396 | end |
|
418 | 397 | end |
|
419 | 398 | |
|
420 | 399 | context "status content" do |
|
421 | 400 | should "appear at the far left, even if it's far in the past" do |
|
422 | 401 | @gantt.instance_variable_set('@date_to', 2.weeks.ago.to_date) |
|
423 | 402 | |
|
424 |
@ |
|
|
403 | @output_buffer = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) | |
|
425 | 404 | assert_select "div.project.label", /#{@project.name}/ |
|
426 | 405 | end |
|
427 | 406 | |
|
428 | 407 | should "show the project name" do |
|
429 |
@ |
|
|
408 | @output_buffer = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) | |
|
430 | 409 | assert_select "div.project.label", /#{@project.name}/ |
|
431 | 410 | end |
|
432 | 411 | |
|
433 | 412 | should_eventually "show the percent complete" do |
|
434 |
@ |
|
|
413 | @output_buffer = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) | |
|
435 | 414 | assert_select "div.project.label", /0%/ |
|
436 | 415 | end |
|
437 | 416 | end |
|
438 | 417 | end |
|
439 | 418 | |
|
440 | 419 | should "test the PNG format" |
|
441 | 420 | should "test the PDF format" |
|
442 | 421 | end |
|
443 | 422 | |
|
444 | 423 | context "#subject_for_version" do |
|
445 | 424 | setup do |
|
446 | 425 | create_gantt |
|
447 | 426 | @project.enabled_module_names = [:issue_tracking] |
|
448 | 427 | @tracker = Tracker.generate! |
|
449 | 428 | @project.trackers << @tracker |
|
450 | 429 | @version = Version.generate!(:effective_date => Date.yesterday) |
|
451 | 430 | @project.versions << @version |
|
452 | 431 | |
|
453 | 432 | @project.issues << Issue.generate!(:fixed_version => @version, |
|
454 | 433 | :subject => "gantt#subject_for_version", |
|
455 | 434 | :tracker => @tracker, |
|
456 | 435 | :project => @project, |
|
457 | 436 | :start_date => Date.today) |
|
458 | 437 | |
|
459 | 438 | end |
|
460 | 439 | |
|
461 | 440 | context ":html format" do |
|
462 | 441 | should "add an absolute positioned div" do |
|
463 |
@ |
|
|
442 | @output_buffer = @gantt.subject_for_version(@version, {:format => :html}) | |
|
464 | 443 | assert_select "div[style*=absolute]" |
|
465 | 444 | end |
|
466 | 445 | |
|
467 | 446 | should "use the indent option to move the div to the right" do |
|
468 |
@ |
|
|
447 | @output_buffer = @gantt.subject_for_version(@version, {:format => :html, :indent => 40}) | |
|
469 | 448 | assert_select "div[style*=left:40]" |
|
470 | 449 | end |
|
471 | 450 | |
|
472 | 451 | should "include the version name" do |
|
473 |
@ |
|
|
452 | @output_buffer = @gantt.subject_for_version(@version, {:format => :html}) | |
|
474 | 453 | assert_select 'div', :text => /#{@version.name}/ |
|
475 | 454 | end |
|
476 | 455 | |
|
477 | 456 | should "include a link to the version" do |
|
478 |
@ |
|
|
457 | @output_buffer = @gantt.subject_for_version(@version, {:format => :html}) | |
|
479 | 458 | assert_select 'a[href=?]', Regexp.escape("/versions/#{@version.to_param}"), :text => /#{@version.name}/ |
|
480 | 459 | end |
|
481 | 460 | |
|
482 | 461 | should "style late versions" do |
|
483 | 462 | assert @version.overdue?, "Need an overdue version for this test" |
|
484 |
@ |
|
|
463 | @output_buffer = @gantt.subject_for_version(@version, {:format => :html}) | |
|
485 | 464 | |
|
486 | 465 | assert_select 'div span.version-behind-schedule' |
|
487 | 466 | end |
|
488 | 467 | |
|
489 | 468 | should "style behind schedule versions" do |
|
490 | 469 | assert @version.behind_schedule?, "Need a behind schedule version for this test" |
|
491 |
@ |
|
|
470 | @output_buffer = @gantt.subject_for_version(@version, {:format => :html}) | |
|
492 | 471 | |
|
493 | 472 | assert_select 'div span.version-behind-schedule' |
|
494 | 473 | end |
|
495 | 474 | end |
|
496 | 475 | should "test the PNG format" |
|
497 | 476 | should "test the PDF format" |
|
498 | 477 | end |
|
499 | 478 | |
|
500 | 479 | context "#line_for_version" do |
|
501 | 480 | setup do |
|
502 | 481 | create_gantt |
|
503 | 482 | @project.enabled_module_names = [:issue_tracking] |
|
504 | 483 | @tracker = Tracker.generate! |
|
505 | 484 | @project.trackers << @tracker |
|
506 | 485 | @version = Version.generate!(:effective_date => 1.week.from_now.to_date) |
|
507 | 486 | @project.versions << @version |
|
508 | 487 | |
|
509 | 488 | @project.issues << Issue.generate!(:fixed_version => @version, |
|
510 | 489 | :subject => "gantt#line_for_project", |
|
511 | 490 | :tracker => @tracker, |
|
512 | 491 | :project => @project, |
|
513 | 492 | :done_ratio => 30, |
|
514 | 493 | :start_date => 1.week.ago.to_date, |
|
515 | 494 | :due_date => 1.week.from_now.to_date) |
|
516 | 495 | end |
|
517 | 496 | |
|
518 | 497 | context ":html format" do |
|
519 | 498 | context "todo line" do |
|
520 | 499 | should "start from the starting point on the left" do |
|
521 |
@ |
|
|
522 |
assert_select "div.version.task_todo[style*=left:28px]", true, @ |
|
|
500 | @output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4}) | |
|
501 | assert_select "div.version.task_todo[style*=left:28px]", true, @output_buffer | |
|
523 | 502 | end |
|
524 | 503 | |
|
525 | 504 | should "be the total width of the version" do |
|
526 |
@ |
|
|
527 |
assert_select "div.version.task_todo[style*=width:58px]", true, @ |
|
|
505 | @output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4}) | |
|
506 | assert_select "div.version.task_todo[style*=width:58px]", true, @output_buffer | |
|
528 | 507 | end |
|
529 | 508 | |
|
530 | 509 | end |
|
531 | 510 | |
|
532 | 511 | context "late line" do |
|
533 | 512 | should "start from the starting point on the left" do |
|
534 |
@ |
|
|
535 |
assert_select "div.version.task_late[style*=left:28px]", true, @ |
|
|
513 | @output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4}) | |
|
514 | assert_select "div.version.task_late[style*=left:28px]", true, @output_buffer | |
|
536 | 515 | end |
|
537 | 516 | |
|
538 | 517 | should "be the total delayed width of the version" do |
|
539 |
@ |
|
|
540 |
assert_select "div.version.task_late[style*=width:30px]", true, @ |
|
|
518 | @output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4}) | |
|
519 | assert_select "div.version.task_late[style*=width:30px]", true, @output_buffer | |
|
541 | 520 | end |
|
542 | 521 | end |
|
543 | 522 | |
|
544 | 523 | context "done line" do |
|
545 | 524 | should "start from the starting point on the left" do |
|
546 |
@ |
|
|
547 |
assert_select "div.version.task_done[style*=left:28px]", true, @ |
|
|
525 | @output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4}) | |
|
526 | assert_select "div.version.task_done[style*=left:28px]", true, @output_buffer | |
|
548 | 527 | end |
|
549 | 528 | |
|
550 | 529 | should "be the total done width of the version" do |
|
551 |
@ |
|
|
552 |
assert_select "div.version.task_done[style*=width:16px]", true, @ |
|
|
530 | @output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4}) | |
|
531 | assert_select "div.version.task_done[style*=width:16px]", true, @output_buffer | |
|
553 | 532 | end |
|
554 | 533 | end |
|
555 | 534 | |
|
556 | 535 | context "starting marker" do |
|
557 | 536 | should "not appear if the starting point is off the gantt chart" do |
|
558 | 537 | # Shift the date range of the chart |
|
559 | 538 | @gantt.instance_variable_set('@date_from', Date.today) |
|
560 | 539 | |
|
561 |
@ |
|
|
540 | @output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4}) | |
|
562 | 541 | assert_select "div.version.starting", false |
|
563 | 542 | end |
|
564 | 543 | |
|
565 | 544 | should "appear at the starting point" do |
|
566 |
@ |
|
|
567 |
assert_select "div.version.starting[style*=left:28px]", true, @ |
|
|
545 | @output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4}) | |
|
546 | assert_select "div.version.starting[style*=left:28px]", true, @output_buffer | |
|
568 | 547 | end |
|
569 | 548 | end |
|
570 | 549 | |
|
571 | 550 | context "ending marker" do |
|
572 | 551 | should "not appear if the starting point is off the gantt chart" do |
|
573 | 552 | # Shift the date range of the chart |
|
574 | 553 | @gantt.instance_variable_set('@date_to', 2.weeks.ago.to_date) |
|
575 | 554 | |
|
576 |
@ |
|
|
555 | @output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4}) | |
|
577 | 556 | assert_select "div.version.ending", false |
|
578 | 557 | |
|
579 | 558 | end |
|
580 | 559 | |
|
581 | 560 | should "appear at the end of the date range" do |
|
582 |
@ |
|
|
583 |
assert_select "div.version.ending[style*=left:88px]", true, @ |
|
|
561 | @output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4}) | |
|
562 | assert_select "div.version.ending[style*=left:88px]", true, @output_buffer | |
|
584 | 563 | end |
|
585 | 564 | end |
|
586 | 565 | |
|
587 | 566 | context "status content" do |
|
588 | 567 | should "appear at the far left, even if it's far in the past" do |
|
589 | 568 | @gantt.instance_variable_set('@date_to', 2.weeks.ago.to_date) |
|
590 | 569 | |
|
591 |
@ |
|
|
570 | @output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4}) | |
|
592 | 571 | assert_select "div.version.label", /#{@version.name}/ |
|
593 | 572 | end |
|
594 | 573 | |
|
595 | 574 | should "show the version name" do |
|
596 |
@ |
|
|
575 | @output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4}) | |
|
597 | 576 | assert_select "div.version.label", /#{@version.name}/ |
|
598 | 577 | end |
|
599 | 578 | |
|
600 | 579 | should "show the percent complete" do |
|
601 |
@ |
|
|
580 | @output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4}) | |
|
602 | 581 | assert_select "div.version.label", /30%/ |
|
603 | 582 | end |
|
604 | 583 | end |
|
605 | 584 | end |
|
606 | 585 | |
|
607 | 586 | should "test the PNG format" |
|
608 | 587 | should "test the PDF format" |
|
609 | 588 | end |
|
610 | 589 | |
|
611 | 590 | context "#subject_for_issue" do |
|
612 | 591 | setup do |
|
613 | 592 | create_gantt |
|
614 | 593 | @project.enabled_module_names = [:issue_tracking] |
|
615 | 594 | @tracker = Tracker.generate! |
|
616 | 595 | @project.trackers << @tracker |
|
617 | 596 | |
|
618 | 597 | @issue = Issue.generate!(:subject => "gantt#subject_for_issue", |
|
619 | 598 | :tracker => @tracker, |
|
620 | 599 | :project => @project, |
|
621 | 600 | :start_date => 3.days.ago.to_date, |
|
622 | 601 | :due_date => Date.yesterday) |
|
623 | 602 | @project.issues << @issue |
|
624 | 603 | |
|
625 | 604 | end |
|
626 | 605 | |
|
627 | 606 | context ":html format" do |
|
628 | 607 | should "add an absolute positioned div" do |
|
629 |
@ |
|
|
608 | @output_buffer = @gantt.subject_for_issue(@issue, {:format => :html}) | |
|
630 | 609 | assert_select "div[style*=absolute]" |
|
631 | 610 | end |
|
632 | 611 | |
|
633 | 612 | should "use the indent option to move the div to the right" do |
|
634 |
@ |
|
|
613 | @output_buffer = @gantt.subject_for_issue(@issue, {:format => :html, :indent => 40}) | |
|
635 | 614 | assert_select "div[style*=left:40]" |
|
636 | 615 | end |
|
637 | 616 | |
|
638 | 617 | should "include the issue subject" do |
|
639 |
@ |
|
|
618 | @output_buffer = @gantt.subject_for_issue(@issue, {:format => :html}) | |
|
640 | 619 | assert_select 'div', :text => /#{@issue.subject}/ |
|
641 | 620 | end |
|
642 | 621 | |
|
643 | 622 | should "include a link to the issue" do |
|
644 |
@ |
|
|
623 | @output_buffer = @gantt.subject_for_issue(@issue, {:format => :html}) | |
|
645 | 624 | assert_select 'a[href=?]', Regexp.escape("/issues/#{@issue.to_param}"), :text => /#{@tracker.name} ##{@issue.id}/ |
|
646 | 625 | end |
|
647 | 626 | |
|
648 | 627 | should "style overdue issues" do |
|
649 | 628 | assert @issue.overdue?, "Need an overdue issue for this test" |
|
650 |
@ |
|
|
629 | @output_buffer = @gantt.subject_for_issue(@issue, {:format => :html}) | |
|
651 | 630 | |
|
652 | 631 | assert_select 'div span.issue-overdue' |
|
653 | 632 | end |
|
654 | 633 | |
|
655 | 634 | end |
|
656 | 635 | should "test the PNG format" |
|
657 | 636 | should "test the PDF format" |
|
658 | 637 | end |
|
659 | 638 | |
|
660 | 639 | context "#line_for_issue" do |
|
661 | 640 | setup do |
|
662 | 641 | create_gantt |
|
663 | 642 | @project.enabled_module_names = [:issue_tracking] |
|
664 | 643 | @tracker = Tracker.generate! |
|
665 | 644 | @project.trackers << @tracker |
|
666 | 645 | @version = Version.generate!(:effective_date => 1.week.from_now.to_date) |
|
667 | 646 | @project.versions << @version |
|
668 | 647 | @issue = Issue.generate!(:fixed_version => @version, |
|
669 | 648 | :subject => "gantt#line_for_project", |
|
670 | 649 | :tracker => @tracker, |
|
671 | 650 | :project => @project, |
|
672 | 651 | :done_ratio => 30, |
|
673 | 652 | :start_date => 1.week.ago.to_date, |
|
674 | 653 | :due_date => 1.week.from_now.to_date) |
|
675 | 654 | @project.issues << @issue |
|
676 | 655 | end |
|
677 | 656 | |
|
678 | 657 | context ":html format" do |
|
679 | 658 | context "todo line" do |
|
680 | 659 | should "start from the starting point on the left" do |
|
681 |
@ |
|
|
682 |
assert_select "div.task_todo[style*=left:28px]", true, @ |
|
|
660 | @output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) | |
|
661 | assert_select "div.task_todo[style*=left:28px]", true, @output_buffer | |
|
683 | 662 | end |
|
684 | 663 | |
|
685 | 664 | should "be the total width of the issue" do |
|
686 |
@ |
|
|
687 |
assert_select "div.task_todo[style*=width:58px]", true, @ |
|
|
665 | @output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) | |
|
666 | assert_select "div.task_todo[style*=width:58px]", true, @output_buffer | |
|
688 | 667 | end |
|
689 | 668 | |
|
690 | 669 | end |
|
691 | 670 | |
|
692 | 671 | context "late line" do |
|
693 | 672 | should "start from the starting point on the left" do |
|
694 |
@ |
|
|
695 |
assert_select "div.task_late[style*=left:28px]", true, @ |
|
|
673 | @output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) | |
|
674 | assert_select "div.task_late[style*=left:28px]", true, @output_buffer | |
|
696 | 675 | end |
|
697 | 676 | |
|
698 | 677 | should "be the total delayed width of the issue" do |
|
699 |
@ |
|
|
700 |
assert_select "div.task_late[style*=width:30px]", true, @ |
|
|
678 | @output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) | |
|
679 | assert_select "div.task_late[style*=width:30px]", true, @output_buffer | |
|
701 | 680 | end |
|
702 | 681 | end |
|
703 | 682 | |
|
704 | 683 | context "done line" do |
|
705 | 684 | should "start from the starting point on the left" do |
|
706 |
@ |
|
|
707 |
assert_select "div.task_done[style*=left:28px]", true, @ |
|
|
685 | @output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) | |
|
686 | assert_select "div.task_done[style*=left:28px]", true, @output_buffer | |
|
708 | 687 | end |
|
709 | 688 | |
|
710 | 689 | should "be the total done width of the issue" do |
|
711 |
@ |
|
|
690 | @output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) | |
|
712 | 691 | # 15 days * 4 px * 30% - 2 px for borders = 16 px |
|
713 |
assert_select "div.task_done[style*=width:16px]", true, @ |
|
|
692 | assert_select "div.task_done[style*=width:16px]", true, @output_buffer | |
|
714 | 693 | end |
|
715 | 694 | |
|
716 | 695 | should "not be the total done width if the chart starts after issue start date" do |
|
717 | 696 | create_gantt(@project, :date_from => 5.days.ago.to_date) |
|
718 | 697 | |
|
719 |
@ |
|
|
720 |
assert_select "div.task_done[style*=left:0px]", true, @ |
|
|
721 |
assert_select "div.task_done[style*=width:8px]", true, @ |
|
|
698 | @output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) | |
|
699 | assert_select "div.task_done[style*=left:0px]", true, @output_buffer | |
|
700 | assert_select "div.task_done[style*=width:8px]", true, @output_buffer | |
|
722 | 701 | end |
|
723 | 702 | |
|
724 | 703 | context "for completed issue" do |
|
725 | 704 | setup do |
|
726 | 705 | @issue.done_ratio = 100 |
|
727 | 706 | end |
|
728 | 707 | |
|
729 | 708 | should "be the total width of the issue" do |
|
730 |
@ |
|
|
731 |
assert_select "div.task_done[style*=width:58px]", true, @ |
|
|
709 | @output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) | |
|
710 | assert_select "div.task_done[style*=width:58px]", true, @output_buffer | |
|
732 | 711 | end |
|
733 | 712 | |
|
734 | 713 | should "be the total width of the issue with due_date=start_date" do |
|
735 | 714 | @issue.due_date = @issue.start_date |
|
736 |
@ |
|
|
737 |
assert_select "div.task_done[style*=width:2px]", true, @ |
|
|
715 | @output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) | |
|
716 | assert_select "div.task_done[style*=width:2px]", true, @output_buffer | |
|
738 | 717 | end |
|
739 | 718 | end |
|
740 | 719 | end |
|
741 | 720 | |
|
742 | 721 | context "status content" do |
|
743 | 722 | should "appear at the far left, even if it's far in the past" do |
|
744 | 723 | @gantt.instance_variable_set('@date_to', 2.weeks.ago.to_date) |
|
745 | 724 | |
|
746 |
@ |
|
|
747 |
assert_select "div.task.label", true, @ |
|
|
725 | @output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) | |
|
726 | assert_select "div.task.label", true, @output_buffer | |
|
748 | 727 | end |
|
749 | 728 | |
|
750 | 729 | should "show the issue status" do |
|
751 |
@ |
|
|
730 | @output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) | |
|
752 | 731 | assert_select "div.task.label", /#{@issue.status.name}/ |
|
753 | 732 | end |
|
754 | 733 | |
|
755 | 734 | should "show the percent complete" do |
|
756 |
@ |
|
|
735 | @output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) | |
|
757 | 736 | assert_select "div.task.label", /30%/ |
|
758 | 737 | end |
|
759 | 738 | end |
|
760 | 739 | end |
|
761 | 740 | |
|
762 | 741 | should "have an issue tooltip" do |
|
763 |
@ |
|
|
742 | @output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) | |
|
764 | 743 | assert_select "div.tooltip", /#{@issue.subject}/ |
|
765 | 744 | end |
|
766 | 745 | |
|
767 | 746 | should "test the PNG format" |
|
768 | 747 | should "test the PDF format" |
|
769 | 748 | end |
|
770 | 749 | |
|
771 | 750 | context "#to_image" do |
|
772 | 751 | should "be tested" |
|
773 | 752 | end |
|
774 | 753 | |
|
775 | 754 | context "#to_pdf" do |
|
776 | 755 | should "be tested" |
|
777 | 756 | end |
|
778 | 757 | |
|
779 | 758 | end |
General Comments 0
You need to be logged in to leave comments.
Login now