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

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.rb
index 62ea0acc5a8..b03bda4f1c3 100644
--- a/app/contracts/work_packages/base_contract.rb
+++ b/app/contracts/work_packages/base_contract.rb
@@ -80,6 +80,7 @@ module WorkPackages
end
attribute :schedule_manually
+ attribute :ignore_non_working_days
attribute :start_date,
writeable: ->(*) {
diff --git a/app/models/type/attributes.rb b/app/models/type/attributes.rb
index 4387cd7175a..24eed20f4e9 100644
--- a/app/models/type/attributes.rb
+++ b/app/models/type/attributes.rb
@@ -32,15 +32,16 @@ module Type::Attributes
EXCLUDED = %w[_type
_dependencies
attribute_groups
- links
- parent_id
- parent
- description
- schedule_manually
derived_start_date
derived_due_date
derived_estimated_time
- duration].freeze
+ ignore_non_working_days
+ duration
+ description
+ links
+ parent_id
+ parent
+ schedule_manually].freeze
included do
# Allow plugins to define constraints
diff --git a/spec/contracts/work_packages/base_contract_spec.rb b/spec/contracts/work_packages/base_contract_spec.rb
index 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 do
end
end
+ 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' do
it_behaves_like 'a parent unwritable property', :done_ratio
diff --git a/spec/models/type_spec.rb b/spec/models/type_spec.rb
index 25957d87724..add1dc7b554 100644
--- a/spec/models/type_spec.rb
+++ b/spec/models/type_spec.rb
@@ -113,25 +113,39 @@ describe ::Type, type: :model do
describe '#work_package_attributes' do
subject { type.work_package_attributes }
+ let(:duration_field_active) { true }
+
before do
allow(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
+ end
end
- 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")
+ end
end
end
end