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