Skip to content
Browse files

Do not calculate due_date for an issue with empty due date when addin…

…g a relation
  • Loading branch information...
1 parent 700c69f commit 898d9a0bd76da6a715ff0ecce982568de1dd442f @kulesa committed
View
14 lib/redmine_better_gantt_chart/issue_dependency_patch.rb
@@ -191,8 +191,8 @@ def max_parent_due(current_parent_id)
# Returns the time scheduled for this issue in working days.
#
def duration_with_work_days
- if start_date && due_date
- RedmineBetterGanttChart::Calendar.workdays_between(start_date, due_date)
+ if self.start_date && self.due_date
+ RedmineBetterGanttChart::Calendar.workdays_between(self.start_date, self.due_date)
else
0
end
@@ -201,11 +201,11 @@ def duration_with_work_days
# Changes behaviour of reschedule_after method
def reschedule_after_with_earlier_date(date)
return if date.nil?
- if start_date.nil? || start_date != date
- if leaf?
- self.start_date, self.due_date = date, RedmineBetterGanttChart::Calendar.workdays_from_date(date, duration - 1)
- else
- self.start_date = date
+
+ if start_date.blank? || start_date != date
+ self.start_date = date
+ if due_date.present?
+ self.due_date = RedmineBetterGanttChart::Calendar.workdays_from_date(date, duration - 1)
end
save
end
View
9 spec/lib/calendar_spec.rb
@@ -37,10 +37,6 @@
subject.workdays_between(friday, friday).should == 1
end
- it "should have 2 working day between today and tomorrow" do
- subject.workdays_between(thursday, friday).should == 2
- end
-
it "should have 6 working days between saturday and next_monday if work on weekends disabled" do
work_on_weekends false
subject.workdays_between(saturday, saturday + 9).should == 6
@@ -111,4 +107,9 @@
next_monday = sunday + 8.days
subject.workdays_from_date(sunday, 6).should == next_monday
end
+
+ it "should return the same day if duration is 0" do
+ work_on_weekends false
+ subject.workdays_from_date(friday, 0).should == friday
+ end
end
View
14 spec/models/issue_patch_spec.rb
@@ -259,5 +259,19 @@
}.should change(@second_issue, :due_date).to(monday + 3)
end
+
+ it "lets create a relation between issues without due dates" do
+ pop = Factory(:issue)
+ parent_issue = Factory(:issue, :start_date => Date.today, :due_date => nil)
+ issue1 = Factory(:issue, :start_date => Date.today, :due_date => nil)
+ issue1.update_attributes!(:parent_issue_id => parent_issue.id)
+ issue2 = Factory(:issue, :start_date => Date.today, :due_date => nil)
+ issue2.update_attributes!(:parent_issue_id => parent_issue.id)
+ relate_issues(issue2, issue1, "follows")
+
+ issue1.reload
+ issue1.relations.count.should == 1
+ end
+
end
end

0 comments on commit 898d9a0

Please sign in to comment.
Something went wrong with that request. Please try again.