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
[37124] Handle the case when estimated hours was set to 0.0 (#9280)
Oliver Güntherec56455edd74
diff --git a/app/models/work_package/exporter/formatters/estimated_hours.rb b/app/models/work_package/exporter/formatters/estimated_hours.rbindex d63f232405d..3236bd5a6c3 100644--- a/app/models/work_package/exporter/formatters/estimated_hours.rb+++ b/app/models/work_package/exporter/formatters/estimated_hours.rb@@ -10,13 +10,21 @@ module WorkPackage::Exporter### Takes a WorkPackage and a QueryColumn and returns the value to be exported.def format(work_package, column, **options)- value = work_package.estimated_hours- derived_estimated_value = work_package.derived_estimated_hours+ estimated_hours = work_package.estimated_hours+ derived_hours = formatted_derived_hours(work_package)- if value.nil? && derived_estimated_value.present?+ if estimated_hours.nil? || derived_hours.nil?+ return estimated_hours || derived_hours+ end++ "#{estimated_hours} #{derived_hours}"+ end++ private++ def formatted_derived_hours(work_package)+ if (derived_estimated_value = work_package.derived_estimated_hours)"(#{derived_estimated_value})"- else- valueendendenddiff --git a/modules/xls_export/spec/models/xls_export/work_package/exporter/xls_integration_spec.rb b/modules/xls_export/spec/models/xls_export/work_package/exporter/xls_integration_spec.rbindex d16d44f6d56..7a12318ed24 100644--- a/modules/xls_export/spec/models/xls_export/work_package/exporter/xls_integration_spec.rb+++ b/modules/xls_export/spec/models/xls_export/work_package/exporter/xls_integration_spec.rb@@ -348,4 +348,23 @@ describe XlsExport::WorkPackage::Exporter::XLS doexpect(estimated_cell).to eq '(15.0)'endend++ describe 'with derived estimated hours and estimated_hours set to zero' do+ let(:work_package) do+ FactoryBot.create(:work_package,+ project: project,+ derived_estimated_hours: 15.0,+ estimated_hours: 0.0,+ type: project.types.first)+ end+ let(:work_packages) { [work_package] }++ let(:column_names) { %w[subject status updated_at estimated_hours] }++ it 'it outputs both values' do+ work_package.reload+ estimated_cell = sheet.rows.last.to_a.last+ expect(estimated_cell).to eq '0.0 (15.0)'+ end+ endend