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
use calculate_duration trait in feature spec instead of defaulting to calculating duration
Ivan Kuchin142862f82dbd
diff --git a/spec/factories/project_phase_factory.rb b/spec/factories/project_phase_factory.rbindex 5fb25bbfd39..81c6229b9ca 100644--- a/spec/factories/project_phase_factory.rb+++ b/spec/factories/project_phase_factory.rb@@ -36,12 +36,8 @@ FactoryBot.define dostart_date { Date.current - 2.days }finish_date { Date.current + 2.days }- duration do- next nil unless date_range_set?-- working_days = Setting.find_by(name: :working_days).value.map(&:to_i)- (start_date..finish_date).count { |d| working_days.include?(d.cwday) }- end+ # use :calculate_duration trait if duration needs to take weekends and non working days into account+ duration { date_range_set? ? finish_date - start_date + 1 : nil }trait :skip_validate doto_create { |instance| instance.save(validate: false) }@@ -60,7 +56,7 @@ FactoryBot.define doend# calculate duration taking weekdays and non working days into account- trait :proper_duration do+ trait :calculate_duration doduration { calculate_duration }endenddiff --git a/spec/features/admin/working_days_spec.rb b/spec/features/admin/working_days_spec.rbindex 0486b0a6a94..6604d14642c 100644--- a/spec/features/admin/working_days_spec.rb+++ b/spec/features/admin/working_days_spec.rb@@ -46,6 +46,7 @@ RSpec.describe "Working Days", :js do# Create consecutive phases with fixed datesshared_let(:phase1) docreate(:project_phase,+ :calculate_duration,project:,definition: phase_definition1,start_date: phase1_start_date,@@ -54,6 +55,7 @@ RSpec.describe "Working Days", :js doshared_let(:phase2) docreate(:project_phase,+ :calculate_duration,project:,definition: phase_definition2,start_date: phase2_start_date,