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