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