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
add ignore flag to work package contracts but hide from form configuration
ulfertsa82fa93a70c6
diff --git a/app/contracts/work_packages/base_contract.rb b/app/contracts/work_packages/base_contract.rbindex 62ea0acc5a8..b03bda4f1c3 100644--- a/app/contracts/work_packages/base_contract.rb+++ b/app/contracts/work_packages/base_contract.rb@@ -80,6 +80,7 @@ module WorkPackagesendattribute :schedule_manually+ attribute :ignore_non_working_daysattribute :start_date,writeable: ->(*) {diff --git a/app/models/type/attributes.rb b/app/models/type/attributes.rbindex 4387cd7175a..24eed20f4e9 100644--- a/app/models/type/attributes.rb+++ b/app/models/type/attributes.rb@@ -32,15 +32,16 @@ module Type::AttributesEXCLUDED = %w[_type_dependenciesattribute_groups- links- parent_id- parent- description- schedule_manuallyderived_start_datederived_due_datederived_estimated_time- duration].freeze+ ignore_non_working_days+ duration+ description+ links+ parent_id+ parent+ schedule_manually].freezeincluded do# Allow plugins to define constraintsdiff --git a/spec/contracts/work_packages/base_contract_spec.rb b/spec/contracts/work_packages/base_contract_spec.rbindex d7d0e852bb1..c9122ee3076 100644--- a/spec/contracts/work_packages/base_contract_spec.rb+++ b/spec/contracts/work_packages/base_contract_spec.rb@@ -550,6 +550,24 @@ describe WorkPackages::BaseContract doendend+ describe 'ignore_non_working_days' do+ context 'when setting the value to true' do+ before do+ work_package.ignore_non_working_days = true+ end++ it_behaves_like 'contract is valid'+ end++ context 'when setting the value to false' do+ before do+ work_package.ignore_non_working_days = false+ end++ it_behaves_like 'contract is valid'+ end+ end+describe 'percentage done' doit_behaves_like 'a parent unwritable property', :done_ratiodiff --git a/spec/models/type_spec.rb b/spec/models/type_spec.rbindex 25957d87724..add1dc7b554 100644--- a/spec/models/type_spec.rb+++ b/spec/models/type_spec.rb@@ -113,25 +113,39 @@ describe ::Type, type: :model dodescribe '#work_package_attributes' dosubject { type.work_package_attributes }+ let(:duration_field_active) { true }+before doallow(OpenProject::FeatureDecisions).to receive(:work_packages_duration_field_active?).and_return(true)end- it 'does not return the duration field' do- expect(subject).not_to have_key("duration")+ context 'for the duration field' do+ it 'does not return true field' do+ expect(subject).not_to have_key("duration")+ end++ context 'when the feature flag is off' do+ let(:duration_field_active) { true }++ it 'does not return the field' do+ expect(subject).not_to have_key("duration")+ end+ endend- context 'when the feature flag is off' do- before do- allow(OpenProject::FeatureDecisions)- .to receive(:work_packages_duration_field_active?)- .and_return(false)+ context 'for the ignore_non_working_days field' do+ it 'does not return duration' do+ expect(subject).not_to have_key("ignore_non_working_days")end- it 'does not return the duration field' do- expect(subject).not_to have_key("duration")+ context 'when the feature flag is off' do+ let(:duration_field_active) { true }++ it 'does not return the duration field' do+ expect(subject).not_to have_key("ignore_non_working_days")+ endendendend