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