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
[#64292] Disabling an incomplete phase leads to inconsistencies
Dombi Attilab99695ab74c2
diff --git a/app/services/project_phases/activation_service.rb b/app/services/project_phases/activation_service.rbindex 6af06964b56..b0da97a277f 100644--- a/app/services/project_phases/activation_service.rb+++ b/app/services/project_phases/activation_service.rb@@ -74,13 +74,7 @@ module ProjectPhasesreturn unless first_definitionphase = project.phases.find_by(definition_id: first_definition.id)- return unless phase.date_range_set?-- if phase.active?- preceding_active_phase(phase) || phase- else- phase- end+ preceding_active_phase(phase) || phaseenddef preceding_active_phase(phase)diff --git a/app/services/project_phases/update_service.rb b/app/services/project_phases/update_service.rbindex 99357f683dc..f9768126560 100644--- a/app/services/project_phases/update_service.rb+++ b/app/services/project_phases/update_service.rb@@ -48,7 +48,7 @@ module ProjectPhasesenddef initial_reschedule_date- model.active? ? model.finish_date + 1 : model.start_date+ model.active? ? Day.next_working(from: model.finish_date).date : model.start_dateenddef following_phasesdiff --git a/spec/features/projects/life_cycle/active_in_project_spec.rb b/spec/features/projects/life_cycle/active_in_project_spec.rbindex 25d94d83cd8..86eb1c5afa5 100644--- a/spec/features/projects/life_cycle/active_in_project_spec.rb+++ b/spec/features/projects/life_cycle/active_in_project_spec.rb@@ -37,6 +37,7 @@ RSpec.describe "Projects life cycle settings", :js, with_flag: { stages_and_gatecreate(:user,member_with_permissions: {project => %w[+ edit_project_phasesselect_project_phases]})diff --git a/spec/services/project_phases/activation_service_spec.rb b/spec/services/project_phases/activation_service_spec.rbindex a5de20d2cf2..a7158361076 100644--- a/spec/services/project_phases/activation_service_spec.rb+++ b/spec/services/project_phases/activation_service_spec.rb@@ -188,12 +188,12 @@ RSpec.describe ProjectPhases::ActivationService, type: :model docontext "without date range" dolet!(:phase1) { create_phase(definition: definitions[1], active: false, start_date: nil, finish_date: nil) }- it "doesn't reschedule" do+ it "reschedules following phases using dates of the closest preceding phase with date range" doservice.call(active: true)expect(phase0.reload).to have_attributes(active: true, start_date: date - 1, finish_date: date - 1)expect(phase1.reload).to have_attributes(active: true, start_date: nil, finish_date: nil)- expect(phase2.reload).to have_attributes(active: true, start_date: date + 7, finish_date: date + 9)+ expect(phase2.reload).to have_attributes(active: true, start_date: date, finish_date: date + 2)endendend@@ -399,36 +399,36 @@ RSpec.describe ProjectPhases::ActivationService, type: :model docontext "with date range" dolet!(:phase1) { create_phase(definition: definitions[1], active: true, start_date: date + 2, finish_date: date + 3) }- it "reschedules following phases using dates of that phase" do+ it "reschedules following phases using dates of the closest preceding phase with date range" doservice.call(active: false)expect(phase0.reload).to have_attributes(active: true, start_date: date - 1, finish_date: date - 1)expect(phase1.reload).to have_attributes(active: false, start_date: date + 2, finish_date: date + 3)- expect(phase2.reload).to have_attributes(active: true, start_date: date + 2, finish_date: date + 4)+ expect(phase2.reload).to have_attributes(active: true, start_date: date, finish_date: date + 2)endendcontext "when already deactivated" dolet!(:phase1) { create_phase(definition: definitions[1], active: false, start_date: date + 2, finish_date: date + 3) }- it "reschedules following phases using dates of that phase" do+ it "reschedules following phases using dates of the closest preceding phase with date range" doservice.call(active: false)expect(phase0.reload).to have_attributes(active: true, start_date: date - 1, finish_date: date - 1)expect(phase1.reload).to have_attributes(active: false, start_date: date + 2, finish_date: date + 3)- expect(phase2.reload).to have_attributes(active: true, start_date: date + 2, finish_date: date + 4)+ expect(phase2.reload).to have_attributes(active: true, start_date: date, finish_date: date + 2)endendcontext "without date range" dolet!(:phase1) { create_phase(definition: definitions[1], active: true, start_date: nil, finish_date: nil) }- it "doesn't reschedule" do+ it "reschedules following phases using dates of the closest preceding phase with date range" doservice.call(active: false)expect(phase0.reload).to have_attributes(active: true, start_date: date - 1, finish_date: date - 1)expect(phase1.reload).to have_attributes(active: false, start_date: nil, finish_date: nil)- expect(phase2.reload).to have_attributes(active: true, start_date: date + 7, finish_date: date + 9)+ expect(phase2.reload).to have_attributes(active: true, start_date: date, finish_date: date + 2)endendenddiff --git a/spec/services/project_phases/update_service_spec.rb b/spec/services/project_phases/update_service_spec.rbindex 949440932fe..bc2df80e644 100644--- a/spec/services/project_phases/update_service_spec.rb+++ b/spec/services/project_phases/update_service_spec.rb@@ -165,6 +165,17 @@ RSpec.describe ProjectPhases::UpdateService, type: :model doendend+ context "for following phase with a start date only" do+ let!(:phase) { create(:project_phase, project:, start_date: date, finish_date: date) }+ let!(:following) { create(:project_phase, project:, start_date: date + 1, finish_date: nil, duration: 3) }++ it "reschedules by moving the start date only" do+ expect(service.call(start_date: date, finish_date: date + 1)).to be_success++ expect(following).to have_attributes(start_date: date + 2, finish_date: nil, duration: 3)+ end+ end+context "for following phase with date range in the past" dolet!(:phase) { create(:project_phase, project:, start_date: date, finish_date: date) }let!(:following) { create(:project_phase, project:, start_date: date - 10, finish_date: date - 10, duration: 3) }