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
[#64628] Clearing the start date of a following phase is not possible
Dombi Attila7c8775533e87
diff --git a/app/forms/projects/life_cycles/form.rb b/app/forms/projects/life_cycles/form.rbindex e77f48c4b4c..69ec67bd2a1 100644--- a/app/forms/projects/life_cycles/form.rb+++ b/app/forms/projects/life_cycles/form.rb@@ -118,14 +118,14 @@ module Projects::LifeCyclesdef value(field_name)case field_namewhen :start_date- model.start_date || model.default_start_date || model.start_date_before_type_cast+ model.start_date || model.start_date_before_type_castwhen :finish_datemodel.finish_date_before_type_castendenddef start_date_disabled?- model.follows_previous_phase? && model.default_start_date.present?+ model.follows_previous_phase? && model.start_date.present?enddef start_date_captiondiff --git a/app/services/project_phases/set_attributes_service.rb b/app/services/project_phases/set_attributes_service.rbindex 59d263b8a7d..bd50bab6bbc 100644--- a/app/services/project_phases/set_attributes_service.rb+++ b/app/services/project_phases/set_attributes_service.rb@@ -36,8 +36,11 @@ module ProjectPhasesprivate- def ensure_default_attributes(_params)- model.start_date ||= model.default_start_date if model.default_start_date.present?+ 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+ endenddef set_calculated_durationdiff --git a/spec/features/projects/life_cycle/overview_page/dialog/update_spec.rb b/spec/features/projects/life_cycle/overview_page/dialog/update_spec.rbindex 2ef95c6ab14..31d676359cc 100644--- a/spec/features/projects/life_cycle/overview_page/dialog/update_spec.rb+++ b/spec/features/projects/life_cycle/overview_page/dialog/update_spec.rb@@ -276,7 +276,13 @@ RSpec.describe "Edit project phases on project overview page", :js, with_flag: {dialog.close- # Opening the Planning phase with no dates+ # Save the Initiating phase to trigger rescheduling on the cleared Planning phase+ dialog = overview_page.open_edit_dialog_for_life_cycle(life_cycle_initiating, wait_angular: true)++ dialog.submit # Saving the dialog is successful+ dialog.expect_closed++ # Opening the Planning phase with the default start datedialog = overview_page.open_edit_dialog_for_life_cycle(life_cycle_planning, wait_angular: true)# The start date automatically succeeds the life_cycle_initiating@@ -313,6 +319,42 @@ RSpec.describe "Edit project phases on project overview page", :js, with_flag: {overview_page.within_life_cycle_container(life_cycle_planning) doexpect(page).to have_text formatted_date_range(life_cycle_planning)end++ # Make the Initiating phase incomplete to allow editing the Planning start date+ life_cycle_initiating.update!(start_date: nil)+ dialog = overview_page.open_edit_dialog_for_life_cycle(life_cycle_planning, wait_angular: true)++ # Clear the start date of life_cycle_planning+ dialog.clear_dates(fields: :start_date)++ dialog.submit # Saving the dialog is successful+ dialog.expect_closed++ # Sidebar shows the refreshed life_cycle_planning+ life_cycle_planning.reload+ overview_page.within_life_cycle_container(life_cycle_planning) do+ expect(page).to have_text formatted_date_range(life_cycle_planning)+ end++ # Planning start date is cleared in the database+ expect(life_cycle_planning).to have_attributes(start_date: nil)++ # Saving the Initiating phase will trigger rescheduling and assigns a start date for Planning+ dialog = overview_page.open_edit_dialog_for_life_cycle(life_cycle_initiating, wait_angular: true)++ dialog.submit # Saving the dialog is successful+ dialog.expect_closed++ # Sidebar shows the refreshed life_cycle_planning+ life_cycle_planning.reload+ overview_page.within_life_cycle_container(life_cycle_planning) do+ expect(page).to have_text formatted_date_range(life_cycle_planning)+ end++ # Planning start date is saved in the database+ # Since the Initiating phase is now incomplete without a duration, the planning+ # starts at the same date as the initiating.+ expect(life_cycle_planning.start_date).to eq(initiating_finish_date)endenddiff --git a/spec/services/project_phases/set_attributes_service_spec.rb b/spec/services/project_phases/set_attributes_service_spec.rbindex 7ab27f1c962..7a5bea3ae02 100644--- a/spec/services/project_phases/set_attributes_service_spec.rb+++ b/spec/services/project_phases/set_attributes_service_spec.rb@@ -108,7 +108,7 @@ RSpec.describe ProjectPhases::SetAttributesService, type: :model doallow(phase).to receive(:default_start_date).and_return(date)end- context "and the previous_date is not set" do+ context "and the previous start date is not set" dolet(:previous_date) { nil }it "sets the model's start_date to the default_start_date" do@@ -116,12 +116,20 @@ RSpec.describe ProjectPhases::SetAttributesService, type: :model doendend- context "and the previous_date is set" do+ context "and the previous start date is set" dolet(:previous_date) { Time.zone.yesterday }it "does not sets the model's start_date to the default_start_date" doexpect { 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+ endendenddiff --git a/spec/support/components/projects/project_life_cycles/edit_dialog.rb b/spec/support/components/projects/project_life_cycles/edit_dialog.rbindex 0bd8c613ce4..046b4fcc244 100644--- a/spec/support/components/projects/project_life_cycles/edit_dialog.rb+++ b/spec/support/components/projects/project_life_cycles/edit_dialog.rb@@ -51,13 +51,15 @@ module Componentsclose if close_after_yieldend- def clear_dates- if has_button?("start_date_clear_button")+ def clear_dates(fields: %i(start_date finish_date))+ fields = Array(fields)++ if fields.include?(:start_date) && has_button?("start_date_clear_button")click_button("start_date_clear_button")wait_for_form_preview_to_reloadend- if has_button?("finish_date_clear_button")+ if fields.include?(:finish_date) && has_button?("finish_date_clear_button")click_button("finish_date_clear_button")wait_for_form_preview_to_reloadend