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

Reschedule phases with 1 day gap after incomplete phases as we do with work packages

Dombi Attila07e708958e05
diff --git a/app/services/project_phases/reschedule_service.rb b/app/services/project_phases/reschedule_service.rb
index 9c49a3874e1..0abdbb1f390 100644
--- a/app/services/project_phases/reschedule_service.rb
+++ b/app/services/project_phases/reschedule_service.rb
@@ -85,7 +85,7 @@ module ProjectPhases
phase.save
- phase.finish_date + 1 if phase.finish_date?
+ (phase.finish_date || phase.start_date) + 1
end
def calculate_start_date(from)
diff --git a/spec/services/project_phases/activation_service_spec.rb b/spec/services/project_phases/activation_service_spec.rb
index 876b52de10e..cbad98fcb83 100644
--- a/spec/services/project_phases/activation_service_spec.rb
+++ b/spec/services/project_phases/activation_service_spec.rb
@@ -182,7 +182,7 @@ RSpec.describe ProjectPhases::ActivationService, type: :model do
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: date, finish_date: nil)
- expect(phase2.reload).to have_attributes(active: true, start_date: date, finish_date: date + 2)
+ expect(phase2.reload).to have_attributes(active: true, start_date: date + 1, finish_date: date + 3)
end
end
@@ -194,7 +194,7 @@ RSpec.describe ProjectPhases::ActivationService, type: :model do
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: date, finish_date: nil)
- expect(phase2.reload).to have_attributes(active: true, start_date: date, finish_date: date + 2)
+ expect(phase2.reload).to have_attributes(active: true, start_date: date + 1, finish_date: date + 3)
end
end
end
@@ -245,7 +245,7 @@ RSpec.describe ProjectPhases::ActivationService, type: :model do
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: date, finish_date: nil)
- expect(phase2.reload).to have_attributes(active: true, start_date: date, finish_date: date + 2)
+ expect(phase2.reload).to have_attributes(active: true, start_date: date + 1, finish_date: date + 3)
end
end
end
@@ -382,7 +382,7 @@ RSpec.describe ProjectPhases::ActivationService, type: :model do
expect(phase0.reload).to have_attributes(active: true, start_date: date - 1, finish_date: nil)
expect(phase1.reload).to have_attributes(active: true, start_date: date, finish_date: nil)
- expect(phase2.reload).to have_attributes(active: true, start_date: date, finish_date: date + 2)
+ expect(phase2.reload).to have_attributes(active: true, start_date: date + 1, finish_date: date + 3)
end
end
@@ -394,7 +394,7 @@ RSpec.describe ProjectPhases::ActivationService, type: :model do
expect(phase0.reload).to have_attributes(active: true, start_date: date - 1, finish_date: nil)
expect(phase1.reload).to have_attributes(active: true, start_date: date, finish_date: nil)
- expect(phase2.reload).to have_attributes(active: true, start_date: date, finish_date: date + 2)
+ expect(phase2.reload).to have_attributes(active: true, start_date: date + 1, finish_date: date + 3)
end
end
end
@@ -433,7 +433,7 @@ RSpec.describe ProjectPhases::ActivationService, type: :model do
expect(phase0.reload).to have_attributes(active: true, start_date: date - 1, finish_date: nil)
expect(phase1.reload).to have_attributes(active: true, start_date: date, finish_date: nil)
- expect(phase2.reload).to have_attributes(active: true, start_date: date, finish_date: date + 2)
+ expect(phase2.reload).to have_attributes(active: true, start_date: date + 1, finish_date: date + 3)
end
end
end
@@ -465,7 +465,7 @@ RSpec.describe ProjectPhases::ActivationService, type: :model do
expect(phase0.reload).to have_attributes(active: true, start_date: nil, finish_date: date - 1)
expect(phase1.reload).to have_attributes(active: true, start_date: date, finish_date: nil)
- expect(phase2.reload).to have_attributes(active: true, start_date: date, finish_date: date + 2)
+ expect(phase2.reload).to have_attributes(active: true, start_date: date + 1, finish_date: date + 3)
end
end
@@ -477,7 +477,7 @@ RSpec.describe ProjectPhases::ActivationService, type: :model do
expect(phase0.reload).to have_attributes(active: true, start_date: nil, finish_date: date - 1)
expect(phase1.reload).to have_attributes(active: true, start_date: date, finish_date: nil)
- expect(phase2.reload).to have_attributes(active: true, start_date: date, finish_date: date + 2)
+ expect(phase2.reload).to have_attributes(active: true, start_date: date + 1, finish_date: date + 3)
end
end
end
@@ -516,7 +516,7 @@ RSpec.describe ProjectPhases::ActivationService, type: :model do
expect(phase0.reload).to have_attributes(active: true, start_date: nil, finish_date: date - 1)
expect(phase1.reload).to have_attributes(active: true, start_date: date, finish_date: nil)
- expect(phase2.reload).to have_attributes(active: true, start_date: date, finish_date: date + 2)
+ expect(phase2.reload).to have_attributes(active: true, start_date: date + 1, finish_date: date + 3)
end
end
end
diff --git a/spec/services/project_phases/reschedule_service_spec.rb b/spec/services/project_phases/reschedule_service_spec.rb
index 13244bfa388..1a242c10858 100644
--- a/spec/services/project_phases/reschedule_service_spec.rb
+++ b/spec/services/project_phases/reschedule_service_spec.rb
@@ -150,7 +150,7 @@ RSpec.describe ProjectPhases::RescheduleService, type: :model do
create(:project_phase, project:, start_date: nil, finish_date: nil, duration: 5),
create(:project_phase, project:, start_date: date, finish_date: date, duration: 13),
# Always ending later than the schedule (rescheduling extends the duration)
- create(:project_phase, project:, start_date: nil, finish_date: [from, date].max + 21, duration: 1),
+ create(:project_phase, project:, start_date: nil, finish_date: [from, date].max + 27, duration: 1),
# Always ending earlier than the schedule (rescheduling shrinks the duration)
create(:project_phase, project:, start_date: nil, finish_date: [from, date].min - 1, duration: 2)
]
@@ -162,11 +162,11 @@ RSpec.describe ProjectPhases::RescheduleService, type: :model do
expect(subject).to be_success
expect(phases[0]).to have_attributes(start_date: from, finish_date: from, duration: 1)
expect(phases[1]).to have_attributes(start_date: from + 1, finish_date: nil, duration: 5)
- expect(phases[2]).to have_attributes(start_date: from + 1, finish_date: nil, duration: 5)
- expect(phases[3]).to have_attributes(start_date: from + 1, finish_date: nil, duration: 5)
- expect(phases[4]).to have_attributes(start_date: from + 1, finish_date: from + 19, duration: 13)
- expect(phases[5]).to have_attributes(start_date: from + 20, finish_date: from + 21, duration: 2)
- expect(phases[6]).to have_attributes(start_date: from + 22, finish_date: from + 22, duration: 1)
+ expect(phases[2]).to have_attributes(start_date: from + 2, finish_date: nil, duration: 5)
+ expect(phases[3]).to have_attributes(start_date: from + 5, finish_date: nil, duration: 5)
+ expect(phases[4]).to have_attributes(start_date: from + 6, finish_date: from + 22, duration: 13)
+ expect(phases[5]).to have_attributes(start_date: from + 23, finish_date: from + 27, duration: 3)
+ expect(phases[6]).to have_attributes(start_date: from + 28, finish_date: from + 28, duration: 1)
end
context "when the from date is earlier than the phases dates" do
@@ -176,11 +176,11 @@ RSpec.describe ProjectPhases::RescheduleService, type: :model do
expect(subject).to be_success
expect(phases[0]).to have_attributes(start_date: from, finish_date: date, duration: 2)
expect(phases[1]).to have_attributes(start_date: date + 1, finish_date: nil, duration: 5)
- expect(phases[2]).to have_attributes(start_date: date + 1, finish_date: nil, duration: 5)
- expect(phases[3]).to have_attributes(start_date: date + 1, finish_date: nil, duration: 5)
- expect(phases[4]).to have_attributes(start_date: date + 1, finish_date: date + 17, duration: 13)
- expect(phases[5]).to have_attributes(start_date: date + 20, finish_date: date + 21, duration: 2)
- expect(phases[6]).to have_attributes(start_date: date + 22, finish_date: date + 22, duration: 1)
+ expect(phases[2]).to have_attributes(start_date: date + 2, finish_date: nil, duration: 5)
+ expect(phases[3]).to have_attributes(start_date: date + 3, finish_date: nil, duration: 5)
+ expect(phases[4]).to have_attributes(start_date: date + 6, finish_date: date + 22, duration: 13)
+ expect(phases[5]).to have_attributes(start_date: date + 23, finish_date: date + 27, duration: 3)
+ expect(phases[6]).to have_attributes(start_date: date + 28, finish_date: date + 28, duration: 1)
end
end
end