| 215 |
215 |
assert_select 'div.gantt_hdr>a', :text => /^[\d-]+$/, :count => 6
|
| 216 |
216 |
end
|
| 217 |
217 |
end
|
|
218 |
|
|
219 |
test 'renders project tree with child issues and bars' do
|
|
220 |
prepare_stable_gantt_data
|
|
221 |
|
|
222 |
@request.session[:user_id] = 2
|
|
223 |
|
|
224 |
project = projects(:projects_001)
|
|
225 |
|
|
226 |
get(:show, params: { project_id: project.id })
|
|
227 |
assert_response :success
|
|
228 |
|
|
229 |
# eCookbook
|
|
230 |
assert_subject_row('div.project-name', row: '0', text: project.name)
|
|
231 |
assert_chart_row('div.task.project.task_todo', row: '0', style_substring: 'left:0px;width:138px')
|
|
232 |
|
|
233 |
assert_issue_row(3, 'Bug #3', row: '1')
|
|
234 |
assert_chart_row('div.task.leaf.task_todo', row: '1', style_substring: 'left:0px;width:38px')
|
|
235 |
|
|
236 |
assert_issue_row(7, 'Bug #7', row: '2')
|
|
237 |
assert_chart_row('div.task.leaf.task_todo', row: '2', style_substring: 'left:16px;width:42px')
|
|
238 |
|
|
239 |
assert_issue_row(1, 'Bug #1', row: '3')
|
|
240 |
assert_chart_row('div.task.leaf.task_todo', row: '3', style_substring: 'left:52px;width:46px')
|
|
241 |
|
|
242 |
# Version 1.0
|
|
243 |
assert_subject_row('div#version-2', row: '4', text: '1.0')
|
|
244 |
assert_chart_row('div.task.version', row: '4', style_substring: 'left:48px;width:90px')
|
|
245 |
|
|
246 |
assert_issue_row(2, 'Feature request #2', row: '5')
|
|
247 |
assert_chart_row('div.task.leaf.task_todo', row: '5', style_substring: 'left:48px;width:90px')
|
|
248 |
|
|
249 |
# Private child of eCookbook
|
|
250 |
assert_subject_row(
|
|
251 |
'div.project-name[data-collapse-expand*="project-5"]',
|
|
252 |
row: '6',
|
|
253 |
text: projects(:projects_005).name
|
|
254 |
)
|
|
255 |
assert_chart_row('div.task.project.task_todo', row: '6', style_substring: 'left:56px;width:6px')
|
|
256 |
|
|
257 |
assert_issue_row(6, 'Bug #6', row: '7')
|
|
258 |
assert_chart_row('div.task.leaf.task_todo', row: '7', style_substring: 'left:56px;width:6px')
|
|
259 |
|
|
260 |
assert_issue_row(9, 'Bug #9', row: '8')
|
|
261 |
assert_chart_row('div.task.leaf.task_todo', row: '8', style_substring: 'left:56px;width:6px')
|
|
262 |
|
|
263 |
assert_issue_row(10, 'Bug #10', row: '9')
|
|
264 |
assert_chart_row('div.task.leaf.task_todo', row: '9', style_substring: 'left:56px;width:6px')
|
|
265 |
assert_select 'div.task[id=?][data-rels*=9]', 'task-todo-issue-10'
|
|
266 |
|
|
267 |
# eCookbook Subproject1
|
|
268 |
assert_subject_row(
|
|
269 |
'div.project-name[data-collapse-expand*="project-3"]',
|
|
270 |
row: '10',
|
|
271 |
text: projects(:projects_003).name
|
|
272 |
)
|
|
273 |
assert_issue_row(5, 'Bug #5', row: '11')
|
|
274 |
assert_issue_row(13, 'Bug #13', row: '12')
|
|
275 |
assert_issue_row(14, 'Bug #14', row: '13')
|
|
276 |
end
|
|
277 |
|
|
278 |
test 'renders chart with selected start month and year' do
|
|
279 |
prepare_stable_gantt_data
|
|
280 |
|
|
281 |
@request.session[:user_id] = 2
|
|
282 |
|
|
283 |
project = projects(:projects_005)
|
|
284 |
|
|
285 |
selected_start = User.current.today.prev_month.beginning_of_month
|
|
286 |
get(
|
|
287 |
:show,
|
|
288 |
params: {
|
|
289 |
project_id: project.id,
|
|
290 |
month: selected_start.month,
|
|
291 |
year: selected_start.year
|
|
292 |
}
|
|
293 |
)
|
|
294 |
assert_response :success
|
|
295 |
|
|
296 |
assert_select 'select#month option[selected=selected][value=?]', selected_start.month.to_s
|
|
297 |
assert_select 'select#year option[selected=selected][value=?]', selected_start.year.to_s
|
|
298 |
|
|
299 |
6.times do |offset|
|
|
300 |
m = selected_start.since(offset.month)
|
|
301 |
assert_select 'div.gantt_hdr > a', text: "#{m.year}-#{m.month}"
|
|
302 |
end
|
|
303 |
|
|
304 |
# eCookbook
|
|
305 |
assert_subject_row('div.project-name', row: '0', text: projects(:projects_001).name)
|
|
306 |
assert_chart_row('div.task.project.task_todo', row: '0', style_substring: 'left:0px;width:258px')
|
|
307 |
|
|
308 |
# Private child of eCookbook
|
|
309 |
assert_subject_row(
|
|
310 |
'div.project-name[data-collapse-expand*="project-5"]',
|
|
311 |
row: '1',
|
|
312 |
text: project.name
|
|
313 |
)
|
|
314 |
assert_chart_row('div.task.project.task_todo', row: '1', style_substring: 'left:176px;width:6px')
|
|
315 |
|
|
316 |
# Bug #6
|
|
317 |
assert_issue_row(6, 'Bug #6', row: '2')
|
|
318 |
assert_chart_row('div.task.leaf.task_todo', row: '2', style_substring: 'left:176px;width:6px')
|
|
319 |
|
|
320 |
# Bug #9
|
|
321 |
assert_issue_row(9, 'Bug #9', row: '3')
|
|
322 |
assert_chart_row('div.task.leaf.task_todo', row: '3', style_substring: 'left:176px;width:6px')
|
|
323 |
|
|
324 |
# Bug #10
|
|
325 |
assert_issue_row(10, 'Bug #10', row: '4')
|
|
326 |
assert_chart_row('div.task.leaf.task_todo', row: '4', style_substring: 'left:176px;width:6px')
|
|
327 |
|
|
328 |
assert_select 'div.task[id=?][data-rels*=9]', 'task-todo-issue-10'
|
|
329 |
end
|
|
330 |
|
|
331 |
test 'shows six months starting from current month' do
|
|
332 |
prepare_stable_gantt_data
|
|
333 |
|
|
334 |
@request.session[:user_id] = 2
|
|
335 |
|
|
336 |
project = projects(:projects_001)
|
|
337 |
|
|
338 |
get :show, params: { project_id: project.id }
|
|
339 |
assert_response :success
|
|
340 |
|
|
341 |
start_of_month = User.current.today.beginning_of_month
|
|
342 |
6.times do |offset|
|
|
343 |
m = start_of_month.since(offset.months)
|
|
344 |
|
|
345 |
assert_select 'div.gantt_hdr > a', text: "#{m.year}-#{m.month}"
|
|
346 |
end
|
|
347 |
|
|
348 |
assert_select 'input#months[value=?]', '6'
|
|
349 |
assert_select 'select#month option[selected=selected][value=?]', User.current.today.month.to_s
|
|
350 |
assert_select 'select#year option[selected=selected][value=?]', User.current.today.year.to_s
|
|
351 |
assert_select 'input#zoom[value=?]', '2'
|
|
352 |
end
|
|
353 |
|
|
354 |
private
|
|
355 |
|
|
356 |
def assert_subject_row(selector, row:, text:)
|
|
357 |
assert_select "div.gantt_subjects form #{selector}[data-number-of-rows=?]", row do
|
|
358 |
assert_select 'a', text: text
|
|
359 |
end
|
|
360 |
end
|
|
361 |
|
|
362 |
def assert_issue_row(issue_id, link_text, row:)
|
|
363 |
selector = "div.gantt_subjects form div#issue-#{issue_id}[data-number-of-rows=\"#{row}\"]"
|
|
364 |
assert_select selector do
|
|
365 |
assert_select 'a.issue', text: link_text
|
|
366 |
end
|
|
367 |
end
|
|
368 |
|
|
369 |
def assert_chart_row(selector, row:, style_substring:)
|
|
370 |
matcher = "#gantt_area #{selector}[data-number-of-rows=?][style*=?]"
|
|
371 |
assert_select matcher, row, style_substring, minimum: 1
|
|
372 |
end
|
|
373 |
|
|
374 |
# Freezes today and resets the start and due dates of issues and versions in the eCookbook project and its descendants to fixed values
|
|
375 |
# so the Gantt layout uses deterministic dates, bar positions stay stable across runs, and the tests remain easy to execute.
|
|
376 |
def prepare_stable_gantt_data
|
|
377 |
issues(:issues_003).update!(start_date: Date.new(2025, 9, 30), due_date: Date.new(2025, 10, 10))
|
|
378 |
issues(:issues_007).update!(start_date: Date.new(2025, 10, 5), due_date: Date.new(2025, 10, 15))
|
|
379 |
issues(:issues_001).update!(start_date: Date.new(2025, 10, 14), due_date: Date.new(2025, 10, 25))
|
|
380 |
issues(:issues_002).update!(start_date: Date.new(2025, 10, 13), due_date: nil)
|
|
381 |
issues(:issues_006).update!(start_date: Date.new(2025, 10, 15), due_date: Date.new(2025, 10, 16))
|
|
382 |
issues(:issues_009).update!(start_date: Date.new(2025, 10, 15), due_date: Date.new(2025, 10, 16))
|
|
383 |
issues(:issues_010).update!(start_date: Date.new(2025, 10, 15), due_date: Date.new(2025, 10, 16))
|
|
384 |
|
|
385 |
Version.find(2).update!(effective_date: Date.new(2025, 11, 4))
|
|
386 |
|
|
387 |
travel_to Date.new(2025, 10, 15)
|
|
388 |
end
|
| 218 |
389 |
end
|