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
Return validation error if duration does not match
Christophe Bliard469474efbedb
diff --git a/spec/contracts/work_packages/base_contract_spec.rb b/spec/contracts/work_packages/base_contract_spec.rbindex 5f9b4c8b6ee..e2a1f1ad1fa 100644--- a/spec/contracts/work_packages/base_contract_spec.rb+++ b/spec/contracts/work_packages/base_contract_spec.rb@@ -527,7 +527,7 @@ describe WorkPackages::BaseContract doenddescribe 'duration', with_flag: { work_packages_duration_field_active: true } do- context 'when setting the duration' do+ context 'when setting duration' dobefore dowork_package.duration = 5end@@ -535,7 +535,7 @@ describe WorkPackages::BaseContract doit_behaves_like 'contract is valid'end- context 'when setting the duration for a milestone type work package' do+ context 'when setting duration for a milestone type work package' dolet(:is_milestone) { true }before do@@ -545,7 +545,7 @@ describe WorkPackages::BaseContract doit_behaves_like 'contract is invalid', duration: :not_available_for_milestonesend- context 'when setting the duration to nil for a milestone type work package' do+ context 'when setting duration to nil for a milestone type work package' dolet(:is_milestone) { true }before do@@ -555,7 +555,7 @@ describe WorkPackages::BaseContract doit_behaves_like 'contract is invalid'end- context 'when setting the duration to 1 for a milestone type work package' do+ context 'when setting duration to 1 for a milestone type work package' dolet(:is_milestone) { true }before do@@ -565,7 +565,7 @@ describe WorkPackages::BaseContract doit_behaves_like 'contract is valid'end- context 'when setting the duration with the feature disabled', with_flag: { work_packages_duration_field_active: false } do+ context 'when setting duration with the feature disabled', with_flag: { work_packages_duration_field_active: false } dobefore dowork_package.duration = 5end@@ -573,7 +573,7 @@ describe WorkPackages::BaseContract doit_behaves_like 'contract is invalid', duration: :error_readonlyend- context 'when setting the duration to 0' do+ context 'when setting duration to 0' dobefore dowork_package.duration = 0end@@ -581,7 +581,7 @@ describe WorkPackages::BaseContract doit_behaves_like 'contract is invalid', duration: :greater_thanend- context 'when setting the duration to a floating point' do+ context 'when setting duration to a floating point' dobefore dowork_package.duration = 4.5end@@ -589,7 +589,7 @@ describe WorkPackages::BaseContract doit_behaves_like 'contract is invalid', duration: :not_an_integerend- context 'when setting the duration to a negative value' do+ context 'when setting duration to a negative value' dobefore dowork_package.duration = -5end@@ -597,8 +597,9 @@ describe WorkPackages::BaseContract doit_behaves_like 'contract is invalid', duration: :greater_thanend- context 'when setting duration as well as the dates' do+ context 'when setting duration and dates' dobefore do+ work_package.ignore_non_working_days = truework_package.duration = 6work_package.start_date = Time.zone.today - 4.dayswork_package.due_date = Time.zone.today + 1.day@@ -607,8 +608,21 @@ describe WorkPackages::BaseContract doit_behaves_like 'contract is valid'end- context 'when setting duration as well as the dates and the duration is too small' do+ context 'when setting duration and dates while covering non-working days' dobefore do+ create(:week_days) # sat and sun are weekends+ work_package.ignore_non_working_days = false+ work_package.duration = 6+ work_package.start_date = "2022-08-22"+ work_package.due_date = "2022-08-29"+ end++ it_behaves_like 'contract is valid'+ end++ context 'when setting duration and dates and duration is too small' do+ before do+ work_package.ignore_non_working_days = truework_package.duration = 5work_package.start_date = Time.zone.today - 4.dayswork_package.due_date = Time.zone.today + 1.day@@ -617,8 +631,21 @@ describe WorkPackages::BaseContract doit_behaves_like 'contract is invalid', duration: :smaller_than_datesend- context 'when setting duration as well as the dates and the duration is too big' do+ context 'when setting duration and dates while covering non-working days and duration is too small' dobefore do+ create(:week_days) # sat and sun are weekends+ work_package.ignore_non_working_days = false+ work_package.duration = 1+ work_package.start_date = "2022-08-22"+ work_package.due_date = "2022-08-29"+ end++ it_behaves_like 'contract is invalid', duration: :smaller_than_dates+ end++ context 'when setting duration and dates and duration is too big' do+ before do+ work_package.ignore_non_working_days = truework_package.duration = 7work_package.start_date = Time.zone.today - 4.dayswork_package.due_date = Time.zone.today + 1.day@@ -627,14 +654,16 @@ describe WorkPackages::BaseContract doit_behaves_like 'contract is invalid', duration: :larger_than_datesend- context 'when setting duration as well as the dates to the same date' do+ context 'when setting duration and dates while covering non-working days and duration is too big' dobefore do- work_package.duration = 1- work_package.start_date = Time.zone.today- work_package.due_date = Time.zone.today+ create(:week_days) # sat and sun are weekends+ work_package.ignore_non_working_days = false+ work_package.duration = 99+ work_package.start_date = "2022-08-22"+ work_package.due_date = "2022-08-29"end- it_behaves_like 'contract is valid'+ it_behaves_like 'contract is invalid', duration: :larger_than_datesendcontext 'when setting start date and due date without duration' do