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