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