Skip to content

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

make reschedule service skip inactive phases

Ivan Kuchin2688457bfa0e
diff --git a/app/services/project_life_cycle_steps/reschedule_service.rb b/app/services/project_life_cycle_steps/reschedule_service.rb
index 4038bfdfd84..b34121b1985 100644
--- a/app/services/project_life_cycle_steps/reschedule_service.rb
+++ b/app/services/project_life_cycle_steps/reschedule_service.rb
@@ -47,6 +47,7 @@ module ProjectLifeCycleSteps
def reschedule_phases(phases:, from:)
phases.each do |phase|
+ next unless phase.active?
next unless phase.date_range_set?
next unless phase.duration&.positive? # not updated using service that sets duration
diff --git a/spec/services/project_life_cycle_steps/reschedule_service_spec.rb b/spec/services/project_life_cycle_steps/reschedule_service_spec.rb
index 2d53f2cd6cd..e03ee2e9b05 100644
--- a/spec/services/project_life_cycle_steps/reschedule_service_spec.rb
+++ b/spec/services/project_life_cycle_steps/reschedule_service_spec.rb
@@ -125,6 +125,22 @@ RSpec.describe ProjectLifeCycleSteps::RescheduleService, type: :model do
end
end
+ context "for inactive phases" do
+ let(:phases) do
+ [
+ create(:project_phase, project:, start_date: date, finish_date: date, duration: 5, active: false),
+ create(:project_phase, project:, start_date: date, finish_date: date, duration: 10)
+ ]
+ end
+
+ it "skips them" do
+ expect(service.call(phases:, from:)).to be_success
+
+ expect(phases[0]).to have_attributes(start_date: date, finish_date: date, duration: 5, active: false)
+ expect(phases[1]).to have_attributes(start_date: from, finish_date: from + 13, duration: 10)
+ end
+ end
+
context "for phases without complete date range" do
let(:phases) do
[