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
Do not set a default date in the Phase::SetAttributesService because now the scheduler takes care of default dates.
Dombi Attilaa21f72a8d807
diff --git a/app/models/project/phase.rb b/app/models/project/phase.rbindex 949bacfce8a..efaec980752 100644--- a/app/models/project/phase.rb+++ b/app/models/project/phase.rb@@ -92,7 +92,7 @@ class Project::Phase < ApplicationRecorddef default_start_datereturn @default_start_date if defined?(@default_start_date)- previous_finish_date = previous_phase&.finish_date+ previous_finish_date = previous_phase.finish_date if follows_previous_phase?@default_start_date = previous_finish_date && Day.next_working(from: previous_finish_date).dateenddiff --git a/app/services/project_phases/set_attributes_service.rb b/app/services/project_phases/set_attributes_service.rbindex bd50bab6bbc..dd5f47dacad 100644--- a/app/services/project_phases/set_attributes_service.rb+++ b/app/services/project_phases/set_attributes_service.rb@@ -35,14 +35,6 @@ module ProjectPhasesendprivate-- def ensure_default_attributes(params)- # Set default start date only when there is no user provided value.- if params[:start_date].nil? && model.default_start_date.present?- model.start_date ||= model.default_start_date- end- end-def set_calculated_durationmodel.duration = model.calculate_durationenddiff --git a/spec/models/project/phase_spec.rb b/spec/models/project/phase_spec.rbindex 6ee1bea270f..ddec300062c 100644--- a/spec/models/project/phase_spec.rb+++ b/spec/models/project/phase_spec.rb@@ -186,16 +186,16 @@ RSpec.describe Project::Phase dodescribe "#default_start_date" doinclude_context "with project phases"- context "when the previous phase has a finish date" do+ context "when the previous phase has a complete date range" doit "returns the next working day after the previous phase finish date" doexpected = Day.next_working(from: phase1.finish_date).dateexpect(phase2.default_start_date).to eq(expected)endend- context "when the previous phase does not have a finish date" do+ context "when the previous phase has an incomplete date range" dobefore do- phase1.update(finish_date: nil)+ phase1.update(start_date: nil)endit "returns nil" dodiff --git a/spec/services/project_phases/set_attributes_service_spec.rb b/spec/services/project_phases/set_attributes_service_spec.rbindex 7a5bea3ae02..a85c9504c30 100644--- a/spec/services/project_phases/set_attributes_service_spec.rb+++ b/spec/services/project_phases/set_attributes_service_spec.rb@@ -97,53 +97,5 @@ RSpec.describe ProjectPhases::SetAttributesService, type: :model doendendend-- describe "setting default start date" do- let(:phase) do- build_stubbed(:project_phase, project:, start_date: previous_date)- end-- context "when there is a default_start_date on the phase" do- before do- allow(phase).to receive(:default_start_date).and_return(date)- end-- context "and the previous start date is not set" do- let(:previous_date) { nil }-- it "sets the model's start_date to the default_start_date" do- expect { subject }.to change(phase, :start_date).from(nil).to(date)- end- end-- context "and the previous start date is set" do- let(:previous_date) { Time.zone.yesterday }-- it "does not sets the model's start_date to the default_start_date" do- expect { subject }.not_to change(phase, :start_date)- end-- context "and the current start date is cleared" do- let(:call_attributes) { { start_date: "", finish_date: date + 27 } }-- it "sets the model's start_date to nil" do- expect { subject }.to change(phase, :start_date).from(previous_date).to(nil)- end- end- end- end-- context "when there is no default_start_date on the phase" do- let(:previous_date) { date }-- before do- allow(phase).to receive(:default_start_date).and_return(nil)- end-- it "does not set the model's start_date" do- expect { subject }.not_to change(phase, :start_date).from(date)- end- end- endendend