OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
fix date inheritance from parents with only one date available
ulfertsd77fa1aeb690
diff --git a/app/services/work_packages/set_attributes_service.rb b/app/services/work_packages/set_attributes_service.rbindex bc987255c21..27d4188ad92 100644--- a/app/services/work_packages/set_attributes_service.rb+++ b/app/services/work_packages/set_attributes_service.rb@@ -281,10 +281,16 @@ class WorkPackages::SetAttributesService < ::BaseServices::SetAttributesenddef parent_start_earlier_than_due?- work_package.parent&.start_date && work_package.parent.start_date < (work_package.due_date || work_package.parent.due_date)+ start = work_package.parent&.start_date+ due = work_package.due_date || work_package.parent&.due_date++ (start && !due) || ((due && start) && (start < due))enddef parent_due_later_than_start?- work_package.parent&.due_date && work_package.parent.due_date > (work_package.start_date || work_package.parent.start_date)+ due = work_package.parent&.due_date+ start = work_package.start_date || work_package.parent&.start_date++ (due && !start) || ((due && start) && (due > start))endenddiff --git a/spec/services/work_packages/set_attributes_service_spec.rb b/spec/services/work_packages/set_attributes_service_spec.rbindex 12b64d823c6..ee37a6886c4 100644--- a/spec/services/work_packages/set_attributes_service_spec.rb+++ b/spec/services/work_packages/set_attributes_service_spec.rb@@ -327,6 +327,48 @@ describe WorkPackages::SetAttributesService, type: :model doendend+ context 'with the parent having start date (no due) and not providing own dates' do+ let(:call_attributes) { { parent: parent } }+ let(:parent_due_date) { nil }++ it_behaves_like 'service call' do+ it "sets the start_date to the parent`s start_date" do+ subject++ expect(work_package.start_date)+ .to eql parent_start_date+ end++ it "sets the due_date to nil" do+ subject++ expect(work_package.due_date)+ .to be_nil+ end+ end+ end++ context 'with the parent having due date (no start) and not providing own dates' do+ let(:call_attributes) { { parent: parent } }+ let(:parent_start_date) { nil }++ it_behaves_like 'service call' do+ it "sets the start_date to nil" do+ subject++ expect(work_package.start_date)+ .to be_nil+ end++ it "sets the due_date to the parent`s due_date" do+ subject++ expect(work_package.due_date)+ .to eql parent_due_date+ end+ end+ end+context 'with the parent having dates but providing own dates' dolet(:call_attributes) { { parent: parent, start_date: Date.today, due_date: Date.today + 1.day } }