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