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