@@ -431,7 +431,24 class Issue < ActiveRecord::Base | |||
|
431 | 431 | end |
|
432 | 432 | |
|
433 | 433 | def soonest_start |
|
434 | @soonest_start ||= relations_to.collect{|relation| relation.successor_soonest_start}.compact.min | |
|
434 | @soonest_start ||= ( | |
|
435 | relations_to.collect{|relation| relation.successor_soonest_start} + | |
|
436 | ancestors.collect(&:soonest_start) | |
|
437 | ).compact.max | |
|
438 | end | |
|
439 | ||
|
440 | def reschedule_after(date) | |
|
441 | return if date.nil? | |
|
442 | if leaf? | |
|
443 | if start_date.nil? || start_date < date | |
|
444 | self.start_date, self.due_date = date, date + duration | |
|
445 | save | |
|
446 | end | |
|
447 | else | |
|
448 | leaves.each do |leaf| | |
|
449 | leaf.reschedule_after(date) | |
|
450 | end | |
|
451 | end | |
|
435 | 452 | end |
|
436 | 453 | |
|
437 | 454 | def <=>(issue) |
@@ -73,9 +73,8 class IssueRelation < ActiveRecord::Base | |||
|
73 | 73 | |
|
74 | 74 | def set_issue_to_dates |
|
75 | 75 | soonest_start = self.successor_soonest_start |
|
76 | if soonest_start && (!issue_to.start_date || issue_to.start_date < soonest_start) | |
|
77 | issue_to.start_date, issue_to.due_date = successor_soonest_start, successor_soonest_start + issue_to.duration | |
|
78 | issue_to.save | |
|
76 | if soonest_start | |
|
77 | issue_to.reschedule_after(soonest_start) | |
|
79 | 78 | end |
|
80 | 79 | end |
|
81 | 80 |
@@ -272,6 +272,21 class IssueNestedSetTest < ActiveSupport::TestCase | |||
|
272 | 272 | create_issue!(:estimated_hours => 7, :parent_issue_id => parent.id) |
|
273 | 273 | assert_equal 12, parent.reload.estimated_hours |
|
274 | 274 | end |
|
275 | ||
|
276 | ||
|
277 | def test_reschuling_a_parent_should_reschedule_subtasks | |
|
278 | parent = create_issue! | |
|
279 | c1 = create_issue!(:start_date => '2010-05-12', :due_date => '2010-05-18', :parent_issue_id => parent.id) | |
|
280 | c2 = create_issue!(:start_date => '2010-06-03', :due_date => '2010-06-10', :parent_issue_id => parent.id) | |
|
281 | parent.reload | |
|
282 | parent.reschedule_after(Date.parse('2010-06-02')) | |
|
283 | c1.reload | |
|
284 | assert_equal [Date.parse('2010-06-02'), Date.parse('2010-06-08')], [c1.start_date, c1.due_date] | |
|
285 | c2.reload | |
|
286 | assert_equal [Date.parse('2010-06-03'), Date.parse('2010-06-10')], [c2.start_date, c2.due_date] # no change | |
|
287 | parent.reload | |
|
288 | assert_equal [Date.parse('2010-06-02'), Date.parse('2010-06-10')], [parent.start_date, parent.due_date] | |
|
289 | end | |
|
275 | 290 | |
|
276 | 291 | def test_project_copy_should_copy_issue_tree |
|
277 | 292 | p = Project.create!(:name => 'Tree copy', :identifier => 'tree-copy', :tracker_ids => [1, 2]) |
General Comments 0
You need to be logged in to leave comments.
Login now