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
[63739] do not format work and remaining work for xls and csv exports
Christophe Bliarde84def8b120a
diff --git a/app/models/work_package/exports/formatters/compound_hours.rb b/app/models/work_package/exports/formatters/compound_hours.rbindex c7f74b03eef..336af54299e 100644--- a/app/models/work_package/exports/formatters/compound_hours.rb+++ b/app/models/work_package/exports/formatters/compound_hours.rb@@ -28,8 +28,8 @@module WorkPackage::Exportsmodule Formattersclass CompoundHours < ::Exports::Formatters::Default- def self.apply?(name, _export_format)- name.to_sym == key+ def self.apply?(name, export_format)+ name.to_sym.in?(%i[estimated_hours remaining_hours]) && export_format == :pdfenddef format(work_package, **)@@ -45,10 +45,6 @@ module WorkPackage::Exportsprivate- def attribute- self.class.key- end-def total_prefix(value)value && "· Σ #{value}"enddiff --git a/app/models/work_package/exports/formatters/estimated_hours.rb b/app/models/work_package/exports/formatters/estimated_hours.rbdeleted file mode 100644index 2746de765d9..00000000000--- a/app/models/work_package/exports/formatters/estimated_hours.rb+++ /dev/null@@ -1,33 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++-module WorkPackage::Exports- module Formatters- class EstimatedHours < ::WorkPackage::Exports::Formatters::CompoundHours- end- end-enddiff --git a/app/models/work_package/exports/formatters/remaining_hours.rb b/app/models/work_package/exports/formatters/remaining_hours.rbdeleted file mode 100644index c46434b7abd..00000000000--- a/app/models/work_package/exports/formatters/remaining_hours.rb+++ /dev/null@@ -1,33 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++-module WorkPackage::Exports- module Formatters- class RemainingHours < ::WorkPackage::Exports::Formatters::CompoundHours- end- end-enddiff --git a/config/initializers/export_formats.rb b/config/initializers/export_formats.rbindex 2883730b622..30255e822d5 100644--- a/config/initializers/export_formats.rb+++ b/config/initializers/export_formats.rb@@ -6,8 +6,7 @@ Rails.application.configure do |application|single WorkPackage, WorkPackage::PDFExport::WorkPackageToPdf- formatter WorkPackage, WorkPackage::Exports::Formatters::EstimatedHours- formatter WorkPackage, WorkPackage::Exports::Formatters::RemainingHours+ formatter WorkPackage, WorkPackage::Exports::Formatters::CompoundHoursformatter WorkPackage, WorkPackage::Exports::Formatters::SpentUnitsformatter WorkPackage, WorkPackage::Exports::Formatters::Hoursformatter WorkPackage, WorkPackage::Exports::Formatters::Daysdiff --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 9e79822d749..f29bf999bfe 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@@ -228,7 +228,17 @@ RSpec.describe XlsExport::WorkPackage::Exporter::XLS do# Check row after header rowhours = sheet.rows[1].values_at(2)- expect(hours).to include("27.5h")+ expect(hours).to include("27.5")+ end++ context "with duration format being set to 'days and hours'", with_settings: { duration_format: "days_and_hours" } do+ it "includes estimated hours unformatted" do+ expect(sheet.rows.size).to eq(4 + 1)++ # Check row after header row+ hours = sheet.rows[1].values_at(2)+ expect(hours).to include("27.5")+ endendend@@ -306,7 +316,7 @@ RSpec.describe XlsExport::WorkPackage::Exporter::XLS doendend- describe "with derived estimated hours" do+ describe "with derived estimated hours only" dolet(:work_package) docreate(:work_package,project:,@@ -317,10 +327,29 @@ RSpec.describe XlsExport::WorkPackage::Exporter::XLS dolet(:column_names) { %w[subject status updated_at estimated_hours] }- it "adapts the datetime fields to the user time zone" do+ it "does not output anything" do+ work_package.reload+ estimated_cell = sheet.rows.last.to_a.last+ expect(estimated_cell).to be_nil+ end+ end++ describe "with estimated hours and derived estimated hours" do+ let(:work_package) do+ create(:work_package,+ project:,+ estimated_hours: 10.0,+ derived_estimated_hours: 15.0,+ type: project.types.first)+ end+ let(:work_packages) { [work_package] }++ let(:column_names) { %w[subject status updated_at estimated_hours] }++ it "outputs only the unformatted estimated hours" dowork_package.reloadestimated_cell = sheet.rows.last.to_a.last- expect(estimated_cell).to eq "· Σ 15h"+ expect(estimated_cell).to eq "10.0"endend@@ -338,11 +367,11 @@ RSpec.describe XlsExport::WorkPackage::Exporter::XLS dolet(:column_names) { %w[subject status updated_at estimated_hours remaining_hours] }- it "outputs both values" do+ it "outputs the unformatted values without the derived values" dowork_package.reloadestimated_cell, remaining_cell = sheet.rows.last.to_a.last(2)- expect(estimated_cell).to eq "0h · Σ 15h"- expect(remaining_cell).to eq "0h · Σ 8h"+ expect(estimated_cell).to eq "0.0"+ expect(remaining_cell).to eq "0.0"endendenddiff --git a/spec/models/work_package/exporter/csv_integration_spec.rb b/spec/models/work_package/exporter/csv_integration_spec.rbindex c09f23e1657..db0f5576aac 100644--- a/spec/models/work_package/exporter/csv_integration_spec.rb+++ b/spec/models/work_package/exporter/csv_integration_spec.rb@@ -67,6 +67,7 @@ RSpec.describe WorkPackage::Exports::CSV, "integration" dosubject: "Ruby encodes ß as '\\xDF' in ISO-8859-1.",description: "\u2022 requires unicode.",assigned_to: user,+ estimated_hours: 10.0,derived_estimated_hours: 15.0,type: type_a,project:@@ -85,7 +86,7 @@ RSpec.describe WorkPackage::Exports::CSV, "integration" doexpect(data.last).to include(work_package.description)expect(data.last).to include(user.name)expect(data.last).to include(work_package.updated_at.in_time_zone(user.time_zone).strftime("%m/%d/%Y %I:%M %p"))- expect(data.last).to include("· Σ 15h")+ expect(data.last).to include("10.0")endend@@ -103,7 +104,7 @@ RSpec.describe WorkPackage::Exports::CSV, "integration" doexpect(data.last).not_to include(work_package.description)expect(data.last).to include(user.name)expect(data.last).to include(work_package.updated_at.in_time_zone(user.time_zone).strftime("%m/%d/%Y %I:%M %p"))- expect(data.last).to include("· Σ 15h")+ expect(data.last).to include("10.0")endendend