@@ -17,26 +17,13 | |||||
17 |
|
17 | |||
18 | require File.expand_path('../../../../../test_helper', __FILE__) |
|
18 | require File.expand_path('../../../../../test_helper', __FILE__) | |
19 |
|
19 | |||
20 |
class Redmine::Helpers::GanttTest < Acti |
|
20 | class Redmine::Helpers::GanttHelperTest < ActionView::TestCase | |
21 | # Utility methods and classes so assert_select can be used. |
|
21 | include ApplicationHelper | |
22 | class GanttViewTest < ActionView::Base |
|
22 | include ProjectsHelper | |
23 | include ActionView::Helpers::UrlHelper |
|
23 | include IssuesHelper | |
24 | include ActionView::Helpers::TextHelper |
|
|||
25 | include ActionController::UrlWriter |
|
|||
26 | include ApplicationHelper |
|
|||
27 | include ProjectsHelper |
|
|||
28 | include IssuesHelper |
|
|||
29 |
|
||||
30 | def self.default_url_options |
|
|||
31 | {:only_path => true } |
|
|||
32 | end |
|
|||
33 |
|
||||
34 | end |
|
|||
35 |
|
||||
36 | include ActionController::Assertions::SelectorAssertions |
|
|||
37 |
|
24 | |||
38 | def setup |
|
25 | def setup | |
39 | @response = ActionController::TestResponse.new |
|
26 | setup_with_controller | |
40 | # Fixtures |
|
27 | # Fixtures | |
41 | ProjectCustomField.delete_all |
|
28 | ProjectCustomField.delete_all | |
42 | Project.destroy_all |
|
29 | Project.destroy_all | |
@@ -44,21 +31,13 class Redmine::Helpers::GanttTest < ActiveSupport::TestCase | |||||
44 | User.current = User.find(1) |
|
31 | User.current = User.find(1) | |
45 | end |
|
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 | # Creates a Gantt chart for a 4 week span |
|
34 | # Creates a Gantt chart for a 4 week span | |
56 | def create_gantt(project=Project.generate!, options={}) |
|
35 | def create_gantt(project=Project.generate!, options={}) | |
57 | @project = project |
|
36 | @project = project | |
58 | @gantt = Redmine::Helpers::Gantt.new(options) |
|
37 | @gantt = Redmine::Helpers::Gantt.new(options) | |
59 | @gantt.project = @project |
|
38 | @gantt.project = @project | |
60 | @gantt.query = Query.generate_default!(:project => @project) |
|
39 | @gantt.query = Query.generate_default!(:project => @project) | |
61 |
@gantt.view = |
|
40 | @gantt.view = self | |
62 | @gantt.instance_variable_set('@date_from', options[:date_from] || 2.weeks.ago.to_date) |
|
41 | @gantt.instance_variable_set('@date_from', options[:date_from] || 2.weeks.ago.to_date) | |
63 | @gantt.instance_variable_set('@date_to', options[:date_to] || 2.weeks.from_now.to_date) |
|
42 | @gantt.instance_variable_set('@date_to', options[:date_to] || 2.weeks.from_now.to_date) | |
64 | end |
|
43 | end | |
@@ -136,24 +115,24 class Redmine::Helpers::GanttTest < ActiveSupport::TestCase | |||||
136 |
|
115 | |||
137 | context "project" do |
|
116 | context "project" do | |
138 | should "be rendered" do |
|
117 | should "be rendered" do | |
139 |
@ |
|
118 | @output_buffer = @gantt.subjects | |
140 | assert_select "div.project-name a", /#{@project.name}/ |
|
119 | assert_select "div.project-name a", /#{@project.name}/ | |
141 | end |
|
120 | end | |
142 |
|
121 | |||
143 | should "have an indent of 4" do |
|
122 | should "have an indent of 4" do | |
144 |
@ |
|
123 | @output_buffer = @gantt.subjects | |
145 | assert_select "div.project-name[style*=left:4px]" |
|
124 | assert_select "div.project-name[style*=left:4px]" | |
146 | end |
|
125 | end | |
147 | end |
|
126 | end | |
148 |
|
127 | |||
149 | context "version" do |
|
128 | context "version" do | |
150 | should "be rendered" do |
|
129 | should "be rendered" do | |
151 |
@ |
|
130 | @output_buffer = @gantt.subjects | |
152 | assert_select "div.version-name a", /#{@version.name}/ |
|
131 | assert_select "div.version-name a", /#{@version.name}/ | |
153 | end |
|
132 | end | |
154 |
|
133 | |||
155 | should "be indented 24 (one level)" do |
|
134 | should "be indented 24 (one level)" do | |
156 |
@ |
|
135 | @output_buffer = @gantt.subjects | |
157 | assert_select "div.version-name[style*=left:24px]" |
|
136 | assert_select "div.version-name[style*=left:24px]" | |
158 | end |
|
137 | end | |
159 |
|
138 | |||
@@ -164,7 +143,7 class Redmine::Helpers::GanttTest < ActiveSupport::TestCase | |||||
164 | end |
|
143 | end | |
165 |
|
144 | |||
166 | should "not be rendered" do |
|
145 | should "not be rendered" do | |
167 |
@ |
|
146 | @output_buffer = @gantt.subjects | |
168 | assert_select "div.version-name a", :text => /#{@version.name}/, :count => 0 |
|
147 | assert_select "div.version-name a", :text => /#{@version.name}/, :count => 0 | |
169 | end |
|
148 | end | |
170 | end |
|
149 | end | |
@@ -172,12 +151,12 class Redmine::Helpers::GanttTest < ActiveSupport::TestCase | |||||
172 |
|
151 | |||
173 | context "issue" do |
|
152 | context "issue" do | |
174 | should "be rendered" do |
|
153 | should "be rendered" do | |
175 |
@ |
|
154 | @output_buffer = @gantt.subjects | |
176 | assert_select "div.issue-subject", /#{@issue.subject}/ |
|
155 | assert_select "div.issue-subject", /#{@issue.subject}/ | |
177 | end |
|
156 | end | |
178 |
|
157 | |||
179 | should "be indented 44 (two levels)" do |
|
158 | should "be indented 44 (two levels)" do | |
180 |
@ |
|
159 | @output_buffer = @gantt.subjects | |
181 | assert_select "div.issue-subject[style*=left:44px]" |
|
160 | assert_select "div.issue-subject[style*=left:44px]" | |
182 | end |
|
161 | end | |
183 |
|
162 | |||
@@ -201,7 +180,7 class Redmine::Helpers::GanttTest < ActiveSupport::TestCase | |||||
201 | end |
|
180 | end | |
202 |
|
181 | |||
203 | should "be rendered" do |
|
182 | should "be rendered" do | |
204 |
@ |
|
183 | @output_buffer = @gantt.subjects | |
205 | assert_select "div.issue-subject", /#{@issue.subject}/ |
|
184 | assert_select "div.issue-subject", /#{@issue.subject}/ | |
206 | end |
|
185 | end | |
207 | end |
|
186 | end | |
@@ -215,14 +194,14 class Redmine::Helpers::GanttTest < ActiveSupport::TestCase | |||||
215 | end |
|
194 | end | |
216 |
|
195 | |||
217 | should "indent subtasks" do |
|
196 | should "indent subtasks" do | |
218 |
@ |
|
197 | @output_buffer = @gantt.subjects | |
219 | # parent task 44px |
|
198 | # parent task 44px | |
220 | assert_select "div.issue-subject[style*=left:44px]", /#{@issue.subject}/ |
|
199 | assert_select "div.issue-subject[style*=left:44px]", /#{@issue.subject}/ | |
221 | # children 64px |
|
200 | # children 64px | |
222 | assert_select "div.issue-subject[style*=left:64px]", /child1/ |
|
201 | assert_select "div.issue-subject[style*=left:64px]", /child1/ | |
223 | assert_select "div.issue-subject[style*=left:64px]", /child2/ |
|
202 | assert_select "div.issue-subject[style*=left:64px]", /child2/ | |
224 | # grandchild 84px |
|
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 | end |
|
205 | end | |
227 | end |
|
206 | end | |
228 | end |
|
207 | end | |
@@ -245,7 +224,7 class Redmine::Helpers::GanttTest < ActiveSupport::TestCase | |||||
245 | :due_date => 1.week.from_now.to_date) |
|
224 | :due_date => 1.week.from_now.to_date) | |
246 | @project.issues << @issue |
|
225 | @project.issues << @issue | |
247 |
|
226 | |||
248 |
@ |
|
227 | @output_buffer = @gantt.lines | |
249 | end |
|
228 | end | |
250 |
|
229 | |||
251 | context "project" do |
|
230 | context "project" do | |
@@ -294,22 +273,22 class Redmine::Helpers::GanttTest < ActiveSupport::TestCase | |||||
294 |
|
273 | |||
295 | context ":html format" do |
|
274 | context ":html format" do | |
296 | should "add an absolute positioned div" do |
|
275 | should "add an absolute positioned div" do | |
297 |
@ |
|
276 | @output_buffer = @gantt.subject_for_project(@project, {:format => :html}) | |
298 | assert_select "div[style*=absolute]" |
|
277 | assert_select "div[style*=absolute]" | |
299 | end |
|
278 | end | |
300 |
|
279 | |||
301 | should "use the indent option to move the div to the right" do |
|
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 | assert_select "div[style*=left:40]" |
|
282 | assert_select "div[style*=left:40]" | |
304 | end |
|
283 | end | |
305 |
|
284 | |||
306 | should "include the project name" do |
|
285 | should "include the project name" do | |
307 |
@ |
|
286 | @output_buffer = @gantt.subject_for_project(@project, {:format => :html}) | |
308 | assert_select 'div', :text => /#{@project.name}/ |
|
287 | assert_select 'div', :text => /#{@project.name}/ | |
309 | end |
|
288 | end | |
310 |
|
289 | |||
311 | should "include a link to the project" do |
|
290 | should "include a link to the project" do | |
312 |
@ |
|
291 | @output_buffer = @gantt.subject_for_project(@project, {:format => :html}) | |
313 | assert_select 'a[href=?]', "/projects/#{@project.identifier}", :text => /#{@project.name}/ |
|
292 | assert_select 'a[href=?]', "/projects/#{@project.identifier}", :text => /#{@project.name}/ | |
314 | end |
|
293 | end | |
315 |
|
294 | |||
@@ -318,7 +297,7 class Redmine::Helpers::GanttTest < ActiveSupport::TestCase | |||||
318 | @project.versions << Version.generate!(:effective_date => Date.yesterday) |
|
297 | @project.versions << Version.generate!(:effective_date => Date.yesterday) | |
319 |
|
298 | |||
320 | assert @project.overdue?, "Need an overdue project for this test" |
|
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 | assert_select 'div span.project-overdue' |
|
302 | assert_select 'div span.project-overdue' | |
324 | end |
|
303 | end | |
@@ -351,38 +330,38 class Redmine::Helpers::GanttTest < ActiveSupport::TestCase | |||||
351 | context ":html format" do |
|
330 | context ":html format" do | |
352 | context "todo line" do |
|
331 | context "todo line" do | |
353 | should "start from the starting point on the left" do |
|
332 | should "start from the starting point on the left" do | |
354 |
@ |
|
333 | @output_buffer = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) | |
355 |
assert_select "div.project.task_todo[style*=left:28px]", true, @ |
|
334 | assert_select "div.project.task_todo[style*=left:28px]", true, @output_buffer | |
356 | end |
|
335 | end | |
357 |
|
336 | |||
358 | should "be the total width of the project" do |
|
337 | should "be the total width of the project" do | |
359 |
@ |
|
338 | @output_buffer = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) | |
360 |
assert_select "div.project.task_todo[style*=width:58px]", true, @ |
|
339 | assert_select "div.project.task_todo[style*=width:58px]", true, @output_buffer | |
361 | end |
|
340 | end | |
362 |
|
341 | |||
363 | end |
|
342 | end | |
364 |
|
343 | |||
365 | context "late line" do |
|
344 | context "late line" do | |
366 | should_eventually "start from the starting point on the left" do |
|
345 | should_eventually "start from the starting point on the left" do | |
367 |
@ |
|
346 | @output_buffer = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) | |
368 |
assert_select "div.project.task_late[style*=left:28px]", true, @ |
|
347 | assert_select "div.project.task_late[style*=left:28px]", true, @output_buffer | |
369 | end |
|
348 | end | |
370 |
|
349 | |||
371 | should_eventually "be the total delayed width of the project" do |
|
350 | should_eventually "be the total delayed width of the project" do | |
372 |
@ |
|
351 | @output_buffer = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) | |
373 |
assert_select "div.project.task_late[style*=width:30px]", true, @ |
|
352 | assert_select "div.project.task_late[style*=width:30px]", true, @output_buffer | |
374 | end |
|
353 | end | |
375 | end |
|
354 | end | |
376 |
|
355 | |||
377 | context "done line" do |
|
356 | context "done line" do | |
378 | should_eventually "start from the starting point on the left" do |
|
357 | should_eventually "start from the starting point on the left" do | |
379 |
@ |
|
358 | @output_buffer = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) | |
380 |
assert_select "div.project.task_done[style*=left:28px]", true, @ |
|
359 | assert_select "div.project.task_done[style*=left:28px]", true, @output_buffer | |
381 | end |
|
360 | end | |
382 |
|
361 | |||
383 | should_eventually "Be the total done width of the project" do |
|
362 | should_eventually "Be the total done width of the project" do | |
384 |
@ |
|
363 | @output_buffer = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) | |
385 |
assert_select "div.project.task_done[style*=width:18px]", true, @ |
|
364 | assert_select "div.project.task_done[style*=width:18px]", true, @output_buffer | |
386 | end |
|
365 | end | |
387 | end |
|
366 | end | |
388 |
|
367 | |||
@@ -391,13 +370,13 class Redmine::Helpers::GanttTest < ActiveSupport::TestCase | |||||
391 | # Shift the date range of the chart |
|
370 | # Shift the date range of the chart | |
392 | @gantt.instance_variable_set('@date_from', Date.today) |
|
371 | @gantt.instance_variable_set('@date_from', Date.today) | |
393 |
|
372 | |||
394 |
@ |
|
373 | @output_buffer = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) | |
395 |
assert_select "div.project.starting", false, @ |
|
374 | assert_select "div.project.starting", false, @output_buffer | |
396 | end |
|
375 | end | |
397 |
|
376 | |||
398 | should "appear at the starting point" do |
|
377 | should "appear at the starting point" do | |
399 |
@ |
|
378 | @output_buffer = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) | |
400 |
assert_select "div.project.starting[style*=left:28px]", true, @ |
|
379 | assert_select "div.project.starting[style*=left:28px]", true, @output_buffer | |
401 | end |
|
380 | end | |
402 | end |
|
381 | end | |
403 |
|
382 | |||
@@ -406,14 +385,14 class Redmine::Helpers::GanttTest < ActiveSupport::TestCase | |||||
406 | # Shift the date range of the chart |
|
385 | # Shift the date range of the chart | |
407 | @gantt.instance_variable_set('@date_to', 2.weeks.ago.to_date) |
|
386 | @gantt.instance_variable_set('@date_to', 2.weeks.ago.to_date) | |
408 |
|
387 | |||
409 |
@ |
|
388 | @output_buffer = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) | |
410 |
assert_select "div.project.ending", false, @ |
|
389 | assert_select "div.project.ending", false, @output_buffer | |
411 |
|
390 | |||
412 | end |
|
391 | end | |
413 |
|
392 | |||
414 | should "appear at the end of the date range" do |
|
393 | should "appear at the end of the date range" do | |
415 |
@ |
|
394 | @output_buffer = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) | |
416 |
assert_select "div.project.ending[style*=left:88px]", true, @ |
|
395 | assert_select "div.project.ending[style*=left:88px]", true, @output_buffer | |
417 | end |
|
396 | end | |
418 | end |
|
397 | end | |
419 |
|
398 | |||
@@ -421,17 +400,17 class Redmine::Helpers::GanttTest < ActiveSupport::TestCase | |||||
421 | should "appear at the far left, even if it's far in the past" do |
|
400 | should "appear at the far left, even if it's far in the past" do | |
422 | @gantt.instance_variable_set('@date_to', 2.weeks.ago.to_date) |
|
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 | assert_select "div.project.label", /#{@project.name}/ |
|
404 | assert_select "div.project.label", /#{@project.name}/ | |
426 | end |
|
405 | end | |
427 |
|
406 | |||
428 | should "show the project name" do |
|
407 | should "show the project name" do | |
429 |
@ |
|
408 | @output_buffer = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) | |
430 | assert_select "div.project.label", /#{@project.name}/ |
|
409 | assert_select "div.project.label", /#{@project.name}/ | |
431 | end |
|
410 | end | |
432 |
|
411 | |||
433 | should_eventually "show the percent complete" do |
|
412 | should_eventually "show the percent complete" do | |
434 |
@ |
|
413 | @output_buffer = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) | |
435 | assert_select "div.project.label", /0%/ |
|
414 | assert_select "div.project.label", /0%/ | |
436 | end |
|
415 | end | |
437 | end |
|
416 | end | |
@@ -460,35 +439,35 class Redmine::Helpers::GanttTest < ActiveSupport::TestCase | |||||
460 |
|
439 | |||
461 | context ":html format" do |
|
440 | context ":html format" do | |
462 | should "add an absolute positioned div" do |
|
441 | should "add an absolute positioned div" do | |
463 |
@ |
|
442 | @output_buffer = @gantt.subject_for_version(@version, {:format => :html}) | |
464 | assert_select "div[style*=absolute]" |
|
443 | assert_select "div[style*=absolute]" | |
465 | end |
|
444 | end | |
466 |
|
445 | |||
467 | should "use the indent option to move the div to the right" do |
|
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 | assert_select "div[style*=left:40]" |
|
448 | assert_select "div[style*=left:40]" | |
470 | end |
|
449 | end | |
471 |
|
450 | |||
472 | should "include the version name" do |
|
451 | should "include the version name" do | |
473 |
@ |
|
452 | @output_buffer = @gantt.subject_for_version(@version, {:format => :html}) | |
474 | assert_select 'div', :text => /#{@version.name}/ |
|
453 | assert_select 'div', :text => /#{@version.name}/ | |
475 | end |
|
454 | end | |
476 |
|
455 | |||
477 | should "include a link to the version" do |
|
456 | should "include a link to the version" do | |
478 |
@ |
|
457 | @output_buffer = @gantt.subject_for_version(@version, {:format => :html}) | |
479 | assert_select 'a[href=?]', Regexp.escape("/versions/#{@version.to_param}"), :text => /#{@version.name}/ |
|
458 | assert_select 'a[href=?]', Regexp.escape("/versions/#{@version.to_param}"), :text => /#{@version.name}/ | |
480 | end |
|
459 | end | |
481 |
|
460 | |||
482 | should "style late versions" do |
|
461 | should "style late versions" do | |
483 | assert @version.overdue?, "Need an overdue version for this test" |
|
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 | assert_select 'div span.version-behind-schedule' |
|
465 | assert_select 'div span.version-behind-schedule' | |
487 | end |
|
466 | end | |
488 |
|
467 | |||
489 | should "style behind schedule versions" do |
|
468 | should "style behind schedule versions" do | |
490 | assert @version.behind_schedule?, "Need a behind schedule version for this test" |
|
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 | assert_select 'div span.version-behind-schedule' |
|
472 | assert_select 'div span.version-behind-schedule' | |
494 | end |
|
473 | end | |
@@ -518,38 +497,38 class Redmine::Helpers::GanttTest < ActiveSupport::TestCase | |||||
518 | context ":html format" do |
|
497 | context ":html format" do | |
519 | context "todo line" do |
|
498 | context "todo line" do | |
520 | should "start from the starting point on the left" do |
|
499 | should "start from the starting point on the left" do | |
521 |
@ |
|
500 | @output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4}) | |
522 |
assert_select "div.version.task_todo[style*=left:28px]", true, @ |
|
501 | assert_select "div.version.task_todo[style*=left:28px]", true, @output_buffer | |
523 | end |
|
502 | end | |
524 |
|
503 | |||
525 | should "be the total width of the version" do |
|
504 | should "be the total width of the version" do | |
526 |
@ |
|
505 | @output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4}) | |
527 |
assert_select "div.version.task_todo[style*=width:58px]", true, @ |
|
506 | assert_select "div.version.task_todo[style*=width:58px]", true, @output_buffer | |
528 | end |
|
507 | end | |
529 |
|
508 | |||
530 | end |
|
509 | end | |
531 |
|
510 | |||
532 | context "late line" do |
|
511 | context "late line" do | |
533 | should "start from the starting point on the left" do |
|
512 | should "start from the starting point on the left" do | |
534 |
@ |
|
513 | @output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4}) | |
535 |
assert_select "div.version.task_late[style*=left:28px]", true, @ |
|
514 | assert_select "div.version.task_late[style*=left:28px]", true, @output_buffer | |
536 | end |
|
515 | end | |
537 |
|
516 | |||
538 | should "be the total delayed width of the version" do |
|
517 | should "be the total delayed width of the version" do | |
539 |
@ |
|
518 | @output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4}) | |
540 |
assert_select "div.version.task_late[style*=width:30px]", true, @ |
|
519 | assert_select "div.version.task_late[style*=width:30px]", true, @output_buffer | |
541 | end |
|
520 | end | |
542 | end |
|
521 | end | |
543 |
|
522 | |||
544 | context "done line" do |
|
523 | context "done line" do | |
545 | should "start from the starting point on the left" do |
|
524 | should "start from the starting point on the left" do | |
546 |
@ |
|
525 | @output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4}) | |
547 |
assert_select "div.version.task_done[style*=left:28px]", true, @ |
|
526 | assert_select "div.version.task_done[style*=left:28px]", true, @output_buffer | |
548 | end |
|
527 | end | |
549 |
|
528 | |||
550 | should "be the total done width of the version" do |
|
529 | should "be the total done width of the version" do | |
551 |
@ |
|
530 | @output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4}) | |
552 |
assert_select "div.version.task_done[style*=width:16px]", true, @ |
|
531 | assert_select "div.version.task_done[style*=width:16px]", true, @output_buffer | |
553 | end |
|
532 | end | |
554 | end |
|
533 | end | |
555 |
|
534 | |||
@@ -558,13 +537,13 class Redmine::Helpers::GanttTest < ActiveSupport::TestCase | |||||
558 | # Shift the date range of the chart |
|
537 | # Shift the date range of the chart | |
559 | @gantt.instance_variable_set('@date_from', Date.today) |
|
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 | assert_select "div.version.starting", false |
|
541 | assert_select "div.version.starting", false | |
563 | end |
|
542 | end | |
564 |
|
543 | |||
565 | should "appear at the starting point" do |
|
544 | should "appear at the starting point" do | |
566 |
@ |
|
545 | @output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4}) | |
567 |
assert_select "div.version.starting[style*=left:28px]", true, @ |
|
546 | assert_select "div.version.starting[style*=left:28px]", true, @output_buffer | |
568 | end |
|
547 | end | |
569 | end |
|
548 | end | |
570 |
|
549 | |||
@@ -573,14 +552,14 class Redmine::Helpers::GanttTest < ActiveSupport::TestCase | |||||
573 | # Shift the date range of the chart |
|
552 | # Shift the date range of the chart | |
574 | @gantt.instance_variable_set('@date_to', 2.weeks.ago.to_date) |
|
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 | assert_select "div.version.ending", false |
|
556 | assert_select "div.version.ending", false | |
578 |
|
557 | |||
579 | end |
|
558 | end | |
580 |
|
559 | |||
581 | should "appear at the end of the date range" do |
|
560 | should "appear at the end of the date range" do | |
582 |
@ |
|
561 | @output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4}) | |
583 |
assert_select "div.version.ending[style*=left:88px]", true, @ |
|
562 | assert_select "div.version.ending[style*=left:88px]", true, @output_buffer | |
584 | end |
|
563 | end | |
585 | end |
|
564 | end | |
586 |
|
565 | |||
@@ -588,17 +567,17 class Redmine::Helpers::GanttTest < ActiveSupport::TestCase | |||||
588 | should "appear at the far left, even if it's far in the past" do |
|
567 | should "appear at the far left, even if it's far in the past" do | |
589 | @gantt.instance_variable_set('@date_to', 2.weeks.ago.to_date) |
|
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 | assert_select "div.version.label", /#{@version.name}/ |
|
571 | assert_select "div.version.label", /#{@version.name}/ | |
593 | end |
|
572 | end | |
594 |
|
573 | |||
595 | should "show the version name" do |
|
574 | should "show the version name" do | |
596 |
@ |
|
575 | @output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4}) | |
597 | assert_select "div.version.label", /#{@version.name}/ |
|
576 | assert_select "div.version.label", /#{@version.name}/ | |
598 | end |
|
577 | end | |
599 |
|
578 | |||
600 | should "show the percent complete" do |
|
579 | should "show the percent complete" do | |
601 |
@ |
|
580 | @output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4}) | |
602 | assert_select "div.version.label", /30%/ |
|
581 | assert_select "div.version.label", /30%/ | |
603 | end |
|
582 | end | |
604 | end |
|
583 | end | |
@@ -626,28 +605,28 class Redmine::Helpers::GanttTest < ActiveSupport::TestCase | |||||
626 |
|
605 | |||
627 | context ":html format" do |
|
606 | context ":html format" do | |
628 | should "add an absolute positioned div" do |
|
607 | should "add an absolute positioned div" do | |
629 |
@ |
|
608 | @output_buffer = @gantt.subject_for_issue(@issue, {:format => :html}) | |
630 | assert_select "div[style*=absolute]" |
|
609 | assert_select "div[style*=absolute]" | |
631 | end |
|
610 | end | |
632 |
|
611 | |||
633 | should "use the indent option to move the div to the right" do |
|
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 | assert_select "div[style*=left:40]" |
|
614 | assert_select "div[style*=left:40]" | |
636 | end |
|
615 | end | |
637 |
|
616 | |||
638 | should "include the issue subject" do |
|
617 | should "include the issue subject" do | |
639 |
@ |
|
618 | @output_buffer = @gantt.subject_for_issue(@issue, {:format => :html}) | |
640 | assert_select 'div', :text => /#{@issue.subject}/ |
|
619 | assert_select 'div', :text => /#{@issue.subject}/ | |
641 | end |
|
620 | end | |
642 |
|
621 | |||
643 | should "include a link to the issue" do |
|
622 | should "include a link to the issue" do | |
644 |
@ |
|
623 | @output_buffer = @gantt.subject_for_issue(@issue, {:format => :html}) | |
645 | assert_select 'a[href=?]', Regexp.escape("/issues/#{@issue.to_param}"), :text => /#{@tracker.name} ##{@issue.id}/ |
|
624 | assert_select 'a[href=?]', Regexp.escape("/issues/#{@issue.to_param}"), :text => /#{@tracker.name} ##{@issue.id}/ | |
646 | end |
|
625 | end | |
647 |
|
626 | |||
648 | should "style overdue issues" do |
|
627 | should "style overdue issues" do | |
649 | assert @issue.overdue?, "Need an overdue issue for this test" |
|
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 | assert_select 'div span.issue-overdue' |
|
631 | assert_select 'div span.issue-overdue' | |
653 | end |
|
632 | end | |
@@ -678,47 +657,47 class Redmine::Helpers::GanttTest < ActiveSupport::TestCase | |||||
678 | context ":html format" do |
|
657 | context ":html format" do | |
679 | context "todo line" do |
|
658 | context "todo line" do | |
680 | should "start from the starting point on the left" do |
|
659 | should "start from the starting point on the left" do | |
681 |
@ |
|
660 | @output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) | |
682 |
assert_select "div.task_todo[style*=left:28px]", true, @ |
|
661 | assert_select "div.task_todo[style*=left:28px]", true, @output_buffer | |
683 | end |
|
662 | end | |
684 |
|
663 | |||
685 | should "be the total width of the issue" do |
|
664 | should "be the total width of the issue" do | |
686 |
@ |
|
665 | @output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) | |
687 |
assert_select "div.task_todo[style*=width:58px]", true, @ |
|
666 | assert_select "div.task_todo[style*=width:58px]", true, @output_buffer | |
688 | end |
|
667 | end | |
689 |
|
668 | |||
690 | end |
|
669 | end | |
691 |
|
670 | |||
692 | context "late line" do |
|
671 | context "late line" do | |
693 | should "start from the starting point on the left" do |
|
672 | should "start from the starting point on the left" do | |
694 |
@ |
|
673 | @output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) | |
695 |
assert_select "div.task_late[style*=left:28px]", true, @ |
|
674 | assert_select "div.task_late[style*=left:28px]", true, @output_buffer | |
696 | end |
|
675 | end | |
697 |
|
676 | |||
698 | should "be the total delayed width of the issue" do |
|
677 | should "be the total delayed width of the issue" do | |
699 |
@ |
|
678 | @output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) | |
700 |
assert_select "div.task_late[style*=width:30px]", true, @ |
|
679 | assert_select "div.task_late[style*=width:30px]", true, @output_buffer | |
701 | end |
|
680 | end | |
702 | end |
|
681 | end | |
703 |
|
682 | |||
704 | context "done line" do |
|
683 | context "done line" do | |
705 | should "start from the starting point on the left" do |
|
684 | should "start from the starting point on the left" do | |
706 |
@ |
|
685 | @output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) | |
707 |
assert_select "div.task_done[style*=left:28px]", true, @ |
|
686 | assert_select "div.task_done[style*=left:28px]", true, @output_buffer | |
708 | end |
|
687 | end | |
709 |
|
688 | |||
710 | should "be the total done width of the issue" do |
|
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 | # 15 days * 4 px * 30% - 2 px for borders = 16 px |
|
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 | end |
|
693 | end | |
715 |
|
694 | |||
716 | should "not be the total done width if the chart starts after issue start date" do |
|
695 | should "not be the total done width if the chart starts after issue start date" do | |
717 | create_gantt(@project, :date_from => 5.days.ago.to_date) |
|
696 | create_gantt(@project, :date_from => 5.days.ago.to_date) | |
718 |
|
697 | |||
719 |
@ |
|
698 | @output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) | |
720 |
assert_select "div.task_done[style*=left:0px]", true, @ |
|
699 | assert_select "div.task_done[style*=left:0px]", true, @output_buffer | |
721 |
assert_select "div.task_done[style*=width:8px]", true, @ |
|
700 | assert_select "div.task_done[style*=width:8px]", true, @output_buffer | |
722 | end |
|
701 | end | |
723 |
|
702 | |||
724 | context "for completed issue" do |
|
703 | context "for completed issue" do | |
@@ -727,14 +706,14 class Redmine::Helpers::GanttTest < ActiveSupport::TestCase | |||||
727 | end |
|
706 | end | |
728 |
|
707 | |||
729 | should "be the total width of the issue" do |
|
708 | should "be the total width of the issue" do | |
730 |
@ |
|
709 | @output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) | |
731 |
assert_select "div.task_done[style*=width:58px]", true, @ |
|
710 | assert_select "div.task_done[style*=width:58px]", true, @output_buffer | |
732 | end |
|
711 | end | |
733 |
|
712 | |||
734 | should "be the total width of the issue with due_date=start_date" do |
|
713 | should "be the total width of the issue with due_date=start_date" do | |
735 | @issue.due_date = @issue.start_date |
|
714 | @issue.due_date = @issue.start_date | |
736 |
@ |
|
715 | @output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) | |
737 |
assert_select "div.task_done[style*=width:2px]", true, @ |
|
716 | assert_select "div.task_done[style*=width:2px]", true, @output_buffer | |
738 | end |
|
717 | end | |
739 | end |
|
718 | end | |
740 | end |
|
719 | end | |
@@ -743,24 +722,24 class Redmine::Helpers::GanttTest < ActiveSupport::TestCase | |||||
743 | should "appear at the far left, even if it's far in the past" do |
|
722 | should "appear at the far left, even if it's far in the past" do | |
744 | @gantt.instance_variable_set('@date_to', 2.weeks.ago.to_date) |
|
723 | @gantt.instance_variable_set('@date_to', 2.weeks.ago.to_date) | |
745 |
|
724 | |||
746 |
@ |
|
725 | @output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) | |
747 |
assert_select "div.task.label", true, @ |
|
726 | assert_select "div.task.label", true, @output_buffer | |
748 | end |
|
727 | end | |
749 |
|
728 | |||
750 | should "show the issue status" do |
|
729 | should "show the issue status" do | |
751 |
@ |
|
730 | @output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) | |
752 | assert_select "div.task.label", /#{@issue.status.name}/ |
|
731 | assert_select "div.task.label", /#{@issue.status.name}/ | |
753 | end |
|
732 | end | |
754 |
|
733 | |||
755 | should "show the percent complete" do |
|
734 | should "show the percent complete" do | |
756 |
@ |
|
735 | @output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) | |
757 | assert_select "div.task.label", /30%/ |
|
736 | assert_select "div.task.label", /30%/ | |
758 | end |
|
737 | end | |
759 | end |
|
738 | end | |
760 | end |
|
739 | end | |
761 |
|
740 | |||
762 | should "have an issue tooltip" do |
|
741 | should "have an issue tooltip" do | |
763 |
@ |
|
742 | @output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) | |
764 | assert_select "div.tooltip", /#{@issue.subject}/ |
|
743 | assert_select "div.tooltip", /#{@issue.subject}/ | |
765 | end |
|
744 | end | |
766 |
|
745 |
General Comments 0
You need to be logged in to leave comments.
Login now