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 schema representer
ulfertsb314f02c1b8c
diff --git a/config/locales/en.yml b/config/locales/en.ymlindex d82b4ca79f5..2c84ff8dfde 100644--- a/config/locales/en.yml+++ b/config/locales/en.yml@@ -581,7 +581,7 @@ en:duration: "Duration"end_insertion: "End of the insertion"end_deletion: "End of the deletion"- version: "Version"+ ignore_non_working_days: "Ignore non working days"parent: "Parent"parent_issue: "Parent"parent_work_package: "Parent"@@ -593,6 +593,7 @@ en:subproject: "Subproject"time_entries: "Log time"type: "Type"+ version: "Version"watcher: "Watcher"'doorkeeper/application':uid: "Client ID"diff --git a/lib/api/v3/work_packages/schema/work_package_schema_representer.rb b/lib/api/v3/work_packages/schema/work_package_schema_representer.rbindex b42dbe1bafc..b0cfe02823c 100644--- a/lib/api/v3/work_packages/schema/work_package_schema_representer.rb+++ b/lib/api/v3/work_packages/schema/work_package_schema_representer.rb@@ -128,6 +128,12 @@ module APIrequired: false,has_default: true+ schema :ignore_non_working_days,+ type: 'Boolean',+ required: false,+ writable: false,+ show_if: ->(*) { OpenProject::FeatureDecisions.work_packages_duration_field_active? }+schema :start_date,type: 'Date',required: false,diff --git a/spec/lib/api/v3/work_packages/schema/work_package_schema_representer_spec.rb b/spec/lib/api/v3/work_packages/schema/work_package_schema_representer_spec.rbindex 1e6382424ce..bbfd2ae8168 100644--- a/spec/lib/api/v3/work_packages/schema/work_package_schema_representer_spec.rb+++ b/spec/lib/api/v3/work_packages/schema/work_package_schema_representer_spec.rb@@ -348,6 +348,33 @@ describe ::API::V3::WorkPackages::Schema::WorkPackageSchemaRepresenter doendend+ describe 'ignoreNonWorkingDays' do+ 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++ it_behaves_like 'has basic schema properties' do+ let(:path) { 'ignoreNonWorkingDays' }+ let(:type) { 'Boolean' }+ let(:name) { I18n.t('activerecord.attributes.work_package.ignore_non_working_days') }+ let(:required) { false }+ let(:writable) { false }+ end++ context 'when the feature flag is off' do+ let(:feature_active) { false }++ it 'has no ignoreNonWorkingDays attribute' do+ expect(subject).not_to have_json_path('ignoreNonWorkingDays')+ end+ end+ end+describe 'date' dobefore doallow(schema)@@ -1063,13 +1090,18 @@ describe ::API::V3::WorkPackages::Schema::WorkPackageSchemaRepresenter doendit 'does not cache the attribute_groups' do- representer.to_json-- expect(work_package.type)- .to receive(:attribute_groups)- .and_return([])+ call_count = 0+ allow(work_package.type)+ .to receive(:attribute_groups) do+ call_count += 1+ []+ end+ # Rendering two times, the Type#attribute_groups+ # should still be called on the second rendering.representer.to_json+ expect { representer.to_json }+ .to change { call_count }endend