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

fixup! Fix failing tests by deriving dates in factory

Christophe Bliard2fd25eb4f609
diff --git a/spec/factories/work_package_factory.rb b/spec/factories/work_package_factory.rb
index e676866952f..e08e32515f4 100644
--- a/spec/factories/work_package_factory.rb
+++ b/spec/factories/work_package_factory.rb
@@ -45,13 +45,13 @@ FactoryBot.define do
# derive start date if due date and duration were provided
next unless %i[due_date duration].all? { |field| __override_names__.include?(field) }
- days.start_date(due_date&.to_date, duration)
+ due_date && duration && days.start_date(due_date.to_date, duration)
end
due_date do
# derive due date if start date and duration were provided
next unless %i[start_date duration].all? { |field| __override_names__.include?(field) }
- days.due_date(start_date&.to_date, duration)
+ start_date && duration && days.due_date(start_date.to_date, duration)
end
duration { days.duration(start_date&.to_date, due_date&.to_date) }
diff --git a/spec/models/queries/work_packages/filter/duration_filter_spec.rb b/spec/models/queries/work_packages/filter/duration_filter_spec.rb
index 575da1b1bb6..fa550023631 100644
--- a/spec/models/queries/work_packages/filter/duration_filter_spec.rb
+++ b/spec/models/queries/work_packages/filter/duration_filter_spec.rb
@@ -48,6 +48,7 @@ describe Queries::WorkPackages::Filter::DurationFilter, type: :model do
it_behaves_like 'non ar filter'
describe '#where' do
+ # TODO: 0 duration should not happen in 12.x. Should we remove it?
let!(:work_package_zero_duration) { create(:work_package, duration: 0) }
let!(:work_package_no_duration) { create(:work_package, duration: nil) }
let!(:work_package_with_duration) { create(:work_package, duration: 1) }