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

Fix unit test

Christophe Bliard8d1dd284a0f6
diff --git a/app/services/work_packages/set_attributes_service.rb b/app/services/work_packages/set_attributes_service.rb
index 6b575eb8c1d..232cbf5065a 100644
--- a/app/services/work_packages/set_attributes_service.rb
+++ b/app/services/work_packages/set_attributes_service.rb
@@ -182,11 +182,7 @@ class WorkPackages::SetAttributesService < ::BaseServices::SetAttributes
def update_duration
return unless date_changed_but_not_duration?
- work_package.duration = if work_package.start_date && work_package.due_date
- work_package.due_date - work_package.start_date + 1
- else
- 1
- end
+ work_package.duration = WorkPackages::Shared::Days.for(work_package).duration(work_package.start_date, work_package.due_date)
end
def set_version_to_nil
diff --git a/spec/services/work_packages/update_service_integration_spec.rb b/spec/services/work_packages/update_service_integration_spec.rb
index 6d5ae3abe22..b088161ed13 100644
--- a/spec/services/work_packages/update_service_integration_spec.rb
+++ b/spec/services/work_packages/update_service_integration_spec.rb
@@ -901,7 +901,8 @@ describe WorkPackages::UpdateService, 'integration tests', type: :model, with_ma
# rubocop:enable RSpec/ExampleLength
end
- describe 'rescheduling work packages with a parent having a follows relation (Regression #43220)' do
+ describe 'rescheduling work packages with a parent having a follows relation (Regression #43220)',
+ with_flag: { work_packages_duration_field_active: true } do
let(:predecessor_work_package_attributes) do
work_package_attributes.merge(
start_date: Time.zone.today + 1.day,