mirror of
https://github.com/redmine/redmine.git
synced 2025-11-12 16:26:03 +01:00
Log automatic rescheduling of following issues to journal (#28649).
git-svn-id: http://svn.redmine.org/redmine/trunk@17373 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -1298,7 +1298,7 @@ class Issue < ActiveRecord::Base
|
|||||||
|
|
||||||
# Reschedules the issue on the given date or the next working day and saves the record.
|
# Reschedules the issue on the given date or the next working day and saves the record.
|
||||||
# If the issue is a parent task, this is done by rescheduling its subtasks.
|
# If the issue is a parent task, this is done by rescheduling its subtasks.
|
||||||
def reschedule_on!(date)
|
def reschedule_on!(date, journal=nil)
|
||||||
return if date.nil?
|
return if date.nil?
|
||||||
if leaf? || !dates_derived?
|
if leaf? || !dates_derived?
|
||||||
if start_date.nil? || start_date != date
|
if start_date.nil? || start_date != date
|
||||||
@@ -1306,6 +1306,9 @@ class Issue < ActiveRecord::Base
|
|||||||
# Issue can not be moved earlier than its soonest start date
|
# Issue can not be moved earlier than its soonest start date
|
||||||
date = [soonest_start(true), date].compact.max
|
date = [soonest_start(true), date].compact.max
|
||||||
end
|
end
|
||||||
|
if journal
|
||||||
|
init_journal(journal.user)
|
||||||
|
end
|
||||||
reschedule_on(date)
|
reschedule_on(date)
|
||||||
begin
|
begin
|
||||||
save
|
save
|
||||||
@@ -1797,7 +1800,7 @@ class Issue < ActiveRecord::Base
|
|||||||
def reschedule_following_issues
|
def reschedule_following_issues
|
||||||
if saved_change_to_start_date? || saved_change_to_due_date?
|
if saved_change_to_start_date? || saved_change_to_due_date?
|
||||||
relations_from.each do |relation|
|
relations_from.each do |relation|
|
||||||
relation.set_issue_to_dates
|
relation.set_issue_to_dates(@current_journal)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -180,10 +180,10 @@ class IssueRelation < ActiveRecord::Base
|
|||||||
set_issue_to_dates
|
set_issue_to_dates
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_issue_to_dates
|
def set_issue_to_dates(journal=nil)
|
||||||
soonest_start = self.successor_soonest_start
|
soonest_start = self.successor_soonest_start
|
||||||
if soonest_start && issue_to
|
if soonest_start && issue_to
|
||||||
issue_to.reschedule_on!(soonest_start)
|
issue_to.reschedule_on!(soonest_start, journal)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -2158,6 +2158,32 @@ class IssueTest < ActiveSupport::TestCase
|
|||||||
assert_equal Date.parse('2012-09-21'), issue2.due_date
|
assert_equal Date.parse('2012-09-21'), issue2.due_date
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_rescheduling_an_issue_to_a_different_due_date_should_add_journal_to_following_issue
|
||||||
|
with_settings :non_working_week_days => [] do
|
||||||
|
issue1 = Issue.generate!(:start_date => '2012-10-15', :due_date => '2012-10-17')
|
||||||
|
issue2 = Issue.generate!(:start_date => '2012-10-18', :due_date => '2012-10-20')
|
||||||
|
IssueRelation.create!(:issue_from => issue1, :issue_to => issue2,
|
||||||
|
:relation_type => IssueRelation::TYPE_PRECEDES)
|
||||||
|
|
||||||
|
assert_difference 'issue2.journals.count' do
|
||||||
|
issue1.reload
|
||||||
|
issue1.init_journal(User.find(3))
|
||||||
|
issue1.due_date = '2012-10-23'
|
||||||
|
issue1.save!
|
||||||
|
end
|
||||||
|
journal = issue2.journals.order(:id).last
|
||||||
|
|
||||||
|
start_date_detail = journal.details.find_by(:prop_key => 'start_date')
|
||||||
|
assert_equal '2012-10-18', start_date_detail.old_value
|
||||||
|
assert_equal '2012-10-24', start_date_detail.value
|
||||||
|
|
||||||
|
due_date_detail = journal.details.find_by(:prop_key => 'due_date')
|
||||||
|
assert_equal '2012-10-20', due_date_detail.old_value
|
||||||
|
assert_equal '2012-10-26', due_date_detail.value
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
def test_rescheduling_reschedule_following_issue_earlier_should_consider_other_preceding_issues
|
def test_rescheduling_reschedule_following_issue_earlier_should_consider_other_preceding_issues
|
||||||
issue1 = Issue.generate!(:start_date => '2012-10-15', :due_date => '2012-10-17')
|
issue1 = Issue.generate!(:start_date => '2012-10-15', :due_date => '2012-10-17')
|
||||||
issue2 = Issue.generate!(:start_date => '2012-10-15', :due_date => '2012-10-17')
|
issue2 = Issue.generate!(:start_date => '2012-10-15', :due_date => '2012-10-17')
|
||||||
|
|||||||
Reference in New Issue
Block a user