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