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
let writability of duration and ignore_non_working_days be govered by feature flag
ulferts122b56332e76
diff --git a/app/contracts/work_packages/base_contract.rb b/app/contracts/work_packages/base_contract.rbindex b03bda4f1c3..2dd08b1c573 100644--- a/app/contracts/work_packages/base_contract.rb+++ b/app/contracts/work_packages/base_contract.rb@@ -80,7 +80,10 @@ module WorkPackagesendattribute :schedule_manually- attribute :ignore_non_working_days+ attribute :ignore_non_working_days,+ writeable: ->(*) {+ OpenProject::FeatureDecisions.work_packages_duration_field_active?+ }attribute :start_date,writeable: ->(*) {@@ -99,7 +102,10 @@ module WorkPackagesmodel.leaf? || model.schedule_manually?}- attribute :duration+ attribute :duration,+ writeable: ->(*) {+ OpenProject::FeatureDecisions.work_packages_duration_field_active?+ }attribute :budgetdiff --git a/lib/api/v3/work_packages/work_package_payload_representer.rb b/lib/api/v3/work_packages/work_package_payload_representer.rbindex 8293edf578f..df9edd8149b 100644--- a/lib/api/v3/work_packages/work_package_payload_representer.rb+++ b/lib/api/v3/work_packages/work_package_payload_representer.rb@@ -36,13 +36,7 @@ module APIcached_representer disabled: truedef writeable_attributes- attributes = super- # TODO: Remove this, once the duration feature is complete- # We have to remove the duration field as it is not being accepted yet.- if OpenProject::FeatureDecisions.work_packages_duration_field_active?- attributes -= %w[duration]- end- attributes + %w[date]+ super + %w[date]enddef load_complete_model(model)diff --git a/spec/contracts/work_packages/base_contract_spec.rb b/spec/contracts/work_packages/base_contract_spec.rbindex c9122ee3076..4b765aa4c31 100644--- a/spec/contracts/work_packages/base_contract_spec.rb+++ b/spec/contracts/work_packages/base_contract_spec.rb@@ -476,7 +476,7 @@ describe WorkPackages::BaseContract doendend- describe 'duration' do+ describe 'duration', with_flag: { work_packages_duration_field_active: true } docontext 'when setting the duration' dobefore dowork_package.duration = 5@@ -485,6 +485,14 @@ 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+ before do+ work_package.duration = 5+ end++ it_behaves_like 'contract is invalid', duration: :error_readonly+ end+context 'when setting the duration to 0' dobefore dowork_package.duration = 0@@ -551,7 +559,7 @@ describe WorkPackages::BaseContract doenddescribe 'ignore_non_working_days' do- context 'when setting the value to true' do+ context 'when setting the value to true', with_flag: { work_packages_duration_field_active: true } dobefore dowork_package.ignore_non_working_days = trueend@@ -559,13 +567,22 @@ describe WorkPackages::BaseContract doit_behaves_like 'contract is valid'end- context 'when setting the value to false' do+ context 'when setting the value to false', with_flag: { work_packages_duration_field_active: true } dobefore dowork_package.ignore_non_working_days = falseendit_behaves_like 'contract is valid'end++ context 'when setting the value to false and with the feature disabled',+ with_flag: { work_packages_duration_field_active: false } do+ before do+ work_package.ignore_non_working_days = false+ end++ it_behaves_like 'contract is invalid', ignore_non_working_days: :error_readonly+ endenddescribe 'percentage done' do