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 representer

ulferts1aaf5ba57a89
diff --git a/docs/api/apiv3/components/schemas/work_package_model.yml b/docs/api/apiv3/components/schemas/work_package_model.yml
index 2a967f8220a..4c821f2574b 100644
--- a/docs/api/apiv3/components/schemas/work_package_model.yml
+++ b/docs/api/apiv3/components/schemas/work_package_model.yml
@@ -76,7 +76,6 @@ properties:
description: |-
**(NOT IMPLEMENTED)** When scheduling, whether or not to ignore the non working days being defined.
A work package with the flag set to true will be allowed to be scheduled to a non working day.
- Not available for milestone type of work packages.
readOnly: true
spentTime:
type: string
diff --git a/docs/api/apiv3/tags/work_packages.yml b/docs/api/apiv3/tags/work_packages.yml
index 53d703f033b..d0037b98862 100644
--- a/docs/api/apiv3/tags/work_packages.yml
+++ b/docs/api/apiv3/tags/work_packages.yml
@@ -60,7 +60,7 @@ description: |-
| duration | The amount of time in hours the work package needs to be completed. | Duration | **(NOT IMPLEMENTED YET)** Not available for milestone type of work packages. | READ | |
| estimatedTime | Time a work package likely needs to be completed excluding its descendants | Duration | | READ / WRITE | |
| derivedEstimatedTime | Time a work package likely needs to be completed including its descendants | Duration | | READ | |
- | ignoreNonWorkingDays | When scheduling, whether or not to ignore the non working days being defined. A work package with the flag set to true will be allowed to be scheduled to a non working day. | Boolean | **(NOT IMPLEMENTED YET)** Not available for milestone type of work packages. | READ | |
+ | ignoreNonWorkingDays | When scheduling, whether or not to ignore the non working days being defined. A work package with the flag set to true will be allowed to be scheduled to a non working day. | Boolean | **(NOT IMPLEMENTED YET)** | READ | |
| spentTime | The time booked for this work package by users working on it | Duration | | READ | **Permission** view time entries |
| percentageDone | Amount of total completion for a work package | Integer | 0 <= x <= 100; Cannot be set for parent work packages | READ / WRITE | |
| createdAt | Time of creation | DateTime | | READ | |
diff --git a/lib/api/v3/work_packages/work_package_representer.rb b/lib/api/v3/work_packages/work_package_representer.rb
index e70c9c2ad51..97c3d30b918 100644
--- a/lib/api/v3/work_packages/work_package_representer.rb
+++ b/lib/api/v3/work_packages/work_package_representer.rb
@@ -402,6 +402,11 @@ module API
end,
render_nil: true
+ property :ignore_non_working_days,
+ if: ->(*) {
+ OpenProject::FeatureDecisions.work_packages_duration_field_active?
+ }
+
property :spent_time,
exec_context: :decorator,
getter: ->(*) do
diff --git a/spec/lib/api/v3/work_packages/work_package_representer_spec.rb b/spec/lib/api/v3/work_packages/work_package_representer_spec.rb
index df0ebb1a0d6..3d907ee5064 100644
--- a/spec/lib/api/v3/work_packages/work_package_representer_spec.rb
+++ b/spec/lib/api/v3/work_packages/work_package_representer_spec.rb
@@ -53,6 +53,7 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter do
let(:derived_due_date) { Time.zone.today - 5.days }
let(:budget) { build_stubbed(:budget, project:) }
let(:duration) { nil }
+ let(:ignore_non_working_days) { true }
let(:work_package) do
build_stubbed(:work_package,
schedule_manually:,
@@ -69,6 +70,7 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter do
estimated_hours:,
derived_estimated_hours:,
budget:,
+ ignore_non_working_days:,
status:) do |wp|
allow(wp)
.to receive(:available_custom_fields)
@@ -299,12 +301,13 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter do
describe 'duration' do
let(:duration) { 6 }
+ let(:feature_active) { true }
before do
# TODO: remove feature flag once the implementation is complete
allow(OpenProject::FeatureDecisions)
.to receive(:work_packages_duration_field_active?)
- .and_return(true)
+ .and_return(feature_active)
end
it { is_expected.to be_json_eql('P6D'.to_json).at_path('duration') }
@@ -326,12 +329,7 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter do
end
context 'when the feature flag is off' do
- before do
- # TODO: remove feature flag once the implementation is complete
- allow(OpenProject::FeatureDecisions)
- .to receive(:work_packages_duration_field_active?)
- .and_return(false)
- end
+ let(:feature_active) { false }
let(:duration) { 6 }
it 'has no duration' do
@@ -340,6 +338,36 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter do
end
end
+ describe 'ignoreNonWorkingDays' do
+ let(:ignore_non_working_days) { true }
+ let(:feature_active) { true }
+
+ before do
+ # TODO: remove feature flag once the implementation is complete
+ allow(OpenProject::FeatureDecisions)
+ .to receive(:work_packages_duration_field_active?)
+ .and_return(feature_active)
+ end
+
+ context 'with the value being `true`' do
+ it { is_expected.to be_json_eql(true.to_json).at_path('ignoreNonWorkingDays') }
+ end
+
+ context 'with the value being `false`' do
+ let(:ignore_non_working_days) { false }
+
+ it { is_expected.to be_json_eql(false.to_json).at_path('ignoreNonWorkingDays') }
+ end
+
+ context 'when the feature flag is off' do
+ let(:feature_active) { false }
+
+ it 'has no ignoreNonWorkingDays' do
+ is_expected.to_not have_json_path('ignoreNonWorkingDays')
+ end
+ end
+ end
+
describe 'createdAt' do
it_behaves_like 'has UTC ISO 8601 date and time' do
let(:date) { work_package.created_at }