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
[#49690] Sums table only shows total sum
as-opa01338ee82a9
diff --git a/spec/models/work_packages/pdf_export/work_package_list_to_pdf_spec.rb b/spec/models/work_packages/pdf_export/work_package_list_to_pdf_spec.rbindex 61bdea94e88..11d7e1340ff 100644--- a/spec/models/work_packages/pdf_export/work_package_list_to_pdf_spec.rb+++ b/spec/models/work_packages/pdf_export/work_package_list_to_pdf_spec.rb@@ -31,9 +31,21 @@ require 'spec_helper'RSpec.describe WorkPackage::PDFExport::WorkPackageListToPdf doinclude Redmine::I18ninclude PDFExportSpecUtils++ let!(:list_custom_field) do+ create(:list_wp_custom_field, multi_value: true, possible_values: ["Foo", "Bar"])+ end+ let(:custom_value_first) do+ create(:work_package_custom_value, custom_field: list_custom_field, value: list_custom_field.custom_options.first.id)+ end+ let(:custom_value_second) do+ create(:work_package_custom_value, custom_field: list_custom_field, value: list_custom_field.custom_options.last.id)+ end+let(:type_standard) { create(:type_standard) }let(:type_bug) { create(:type_bug) }- let(:project) { create(:project, name: 'Foo Bla. Report No. 4/2021 with/for Case 42', types: [type_standard, type_bug]) }+ let(:types) { [type_standard, type_bug] }+ let(:project) { create(:project, name: 'Foo Bla. Report No. 4/2021 with/for Case 42', types:, work_package_custom_fields: [list_custom_field]) }let(:user) docreate(:user,member_in_project: project,@@ -47,7 +59,9 @@ RSpec.describe WorkPackage::PDFExport::WorkPackageListToPdf dotype: type_standard,subject: 'Work package 1',story_points: 1,- description: 'This is a description')+ description: 'This is a description',+ custom_values: [custom_value_first, custom_value_second]+ )endlet(:work_package_child) docreate(:work_package,@@ -56,7 +70,9 @@ RSpec.describe WorkPackage::PDFExport::WorkPackageListToPdf dotype: type_bug,subject: 'Work package 2',story_points: 2,- description: 'This is work package 2')+ description: 'This is work package 2',+ custom_values: [custom_value_first]+ )endlet(:work_packages) do[work_package_parent, work_package_child]@@ -80,7 +96,7 @@ RSpec.describe WorkPackage::PDFExport::WorkPackageListToPdf doexport.export!endend- let(:column_names) { %i[id subject status story_points] }+ let(:column_names) { %w[id subject status story_points] + [list_custom_field.column_name] }def work_packages_sumwork_package_parent.story_points + work_package_child.story_points@@ -102,12 +118,18 @@ RSpec.describe WorkPackage::PDFExport::WorkPackageListToPdf do[project.name, query.name, user.name, export_time_formatted]end+ def show+ cmd = "open -a Preview #{export_pdf.content.path}"+ `#{cmd}`+ end+subject(:pdf) doPDF::Inspector::Text.analyze(File.read(export_pdf.content.path))enddescribe 'with a request for a PDF table' doit 'contains correct data' do+ # showexpect(pdf.strings).to eq([query.name,*column_titles,@@ -154,6 +176,25 @@ RSpec.describe WorkPackage::PDFExport::WorkPackageListToPdf doendend+ describe 'with a request for a PDF table grouped by a custom field with sums' do+ let(:query_attributes) { { group_by: list_custom_field.column_name, display_sums: true } }++ it 'contains correct data' do+ expect(pdf.strings).to eq([+ query.name,+ work_package_parent.type.name,+ *column_titles,+ *work_package_columns(work_package_parent),+ I18n.t('js.label_sum'), work_package_parent.story_points.to_s,+ work_package_child.type.name,+ *column_titles,+ *work_package_columns(work_package_child),+ I18n.t('js.label_sum'), work_package_child.story_points.to_s,+ '1/1', export_time_formatted, query.name+ ])+ end+ end+describe 'with a request for a PDF Report' dolet(:options) { { show_report: true } }