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