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