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

[#64591] Link CF in PDF report only partially clickable when in multiple lines

as-op9d0720bcfd61
diff --git a/Gemfile b/Gemfile
index cac0a32a5f8..92b6b0c3fb6 100644
--- a/Gemfile
+++ b/Gemfile
@@ -158,7 +158,7 @@ gem "structured_warnings", "~> 0.5.0"
gem "airbrake", "~> 13.0.0", require: false
gem "markly", "~> 0.13" # another markdown parser like commonmarker, but with AST support used in PDF export
-gem "md_to_pdf", git: "https://github.com/opf/md-to-pdf", ref: "be1ab00e2c49ce2e5e08a4edb4733438081c53ab"
+gem "md_to_pdf", git: "https://github.com/opf/md-to-pdf", ref: "9961752e4d1e990ec1d4bf48436de9277838763f"
gem "prawn", "~> 2.4"
gem "ttfunk", "~> 1.7.0" # remove after https://github.com/prawnpdf/prawn/issues/1346 resolved.
diff --git a/Gemfile.lock b/Gemfile.lock
index b95b2dd53ec..c6dcf657c45 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -8,10 +8,10 @@ GIT
GIT
remote: https://github.com/opf/md-to-pdf
- revision: be1ab00e2c49ce2e5e08a4edb4733438081c53ab
- ref: be1ab00e2c49ce2e5e08a4edb4733438081c53ab
+ revision: 9961752e4d1e990ec1d4bf48436de9277838763f
+ ref: 9961752e4d1e990ec1d4bf48436de9277838763f
specs:
- md_to_pdf (0.2.3)
+ md_to_pdf (0.2.4)
base64 (~> 0.2)
bigdecimal (~> 3.1)
color_conversion (~> 0.1)
@@ -1760,7 +1760,7 @@ CHECKSUMS
marcel (1.0.4) sha256=0d5649feb64b8f19f3d3468b96c680bae9746335d02194270287868a661516a4
markly (0.13.0) sha256=326a232c876cd95093d110b8d184be8effeadd776c3ffcefd59bdc8de7f59e0d
matrix (0.4.3) sha256=a0d5ab7ddcc1973ff690ab361b67f359acbb16958d1dc072b8b956a286564c5b
- md_to_pdf (0.2.3)
+ md_to_pdf (0.2.4)
messagebird-rest (1.4.2) sha256=1501e16ad76c87558f20f3b26cb39d05f587b349b44b8bf8056b040e9b495301
meta-tags (2.22.1) sha256=e5ae1febbd320d396c7226d7edb868e5d63466c14b9c8b06622a1a74e6dce354
method_source (1.1.0) sha256=181301c9c45b731b4769bc81e8860e72f9161ad7d66dd99103c9ab84f560f5c5
diff --git a/app/models/exports/formatters/custom_field_pdf.rb b/app/models/exports/formatters/custom_field_pdf.rb
index 351e72e23f2..5d3c709d633 100644
--- a/app/models/exports/formatters/custom_field_pdf.rb
+++ b/app/models/exports/formatters/custom_field_pdf.rb
@@ -35,6 +35,13 @@ module Exports
export_format == :pdf && attribute.start_with?("cf_")
end
+ def format_value(value, options)
+ # avoid the value transformed in to a string by the super method
+ return value if value.is_a?(::Exports::Formatters::LinkFormatter)
+
+ super
+ end
+
##
# Print the value meant for PDF export.
#
@@ -44,6 +51,8 @@ module Exports
if custom_field.field_format == "bool"
value = object.typed_custom_value_for(custom_field)
value ? I18n.t(:general_text_Yes) : I18n.t(:general_text_No)
+ elsif custom_field.field_format == "link"
+ LinkFormatter.new(object, custom_field)
else
super
end
diff --git a/app/models/exports/formatters/link_formatter.rb b/app/models/exports/formatters/link_formatter.rb
new file mode 100644
index 00000000000..2eb737bcccf
--- /dev/null
+++ b/app/models/exports/formatters/link_formatter.rb
@@ -0,0 +1,51 @@
+# frozen_string_literal: true
+
+#-- 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 Exports
+ module Formatters
+ class LinkFormatter
+ def initialize(object, custom_field)
+ @href = object.custom_value_for(custom_field).to_s
+ end
+
+ def href
+ @href
+ end
+
+ def to_html
+ ApplicationController.helpers.link_to(@href, @href)
+ end
+
+ def to_s
+ @href
+ end
+ end
+ end
+end
diff --git a/app/models/work_package/exports/macros/attributes.rb b/app/models/work_package/exports/macros/attributes.rb
index 2a938e8bdd3..71f7947b3d4 100644
--- a/app/models/work_package/exports/macros/attributes.rb
+++ b/app/models/work_package/exports/macros/attributes.rb
@@ -162,6 +162,9 @@ module WorkPackage::Exports
def self.format_attribute_value(ar_name, model, obj)
formatter = Exports::Register.formatter_for(model, ar_name, :pdf)
value = formatter.format(obj)
+ # do NOT escape a tag for custom field link
+ return value.to_html if value.is_a?(::Exports::Formatters::LinkFormatter)
+
# important NOT to return empty string as this could change meaning of markdown
# e.g. **to_be_replaced** could be rendered as **** (horizontal line and a *)
value.blank? ? " " : escape_tags(value)
diff --git a/app/models/work_package/exports/macros/links.rb b/app/models/work_package/exports/macros/links.rb
index 5f3b0dcb63b..d0022fe3bf9 100644
--- a/app/models/work_package/exports/macros/links.rb
+++ b/app/models/work_package/exports/macros/links.rb
@@ -48,10 +48,6 @@ module WorkPackage::Exports
[WorkPackagesLinkHandler]
end
- def self.html_replacement?
- true
- end
-
# Faster inclusion check before the full regex is being applied
def self.applicable?(content)
/#\d/.match(content)
diff --git a/app/models/work_package/pdf_export/common/macro.rb b/app/models/work_package/pdf_export/common/macro.rb
index 8eb1fce6cef..26895f07f75 100644
--- a/app/models/work_package/pdf_export/common/macro.rb
+++ b/app/models/work_package/pdf_export/common/macro.rb
@@ -70,17 +70,13 @@ module WorkPackage::PDFExport::Common::Macro
end
def apply_macros_node_text(node, context)
- formatted, applied_macros = apply_macro_text(node.string_content, context)
+ formatted = apply_macro_text(node.string_content, context)
return if formatted == node.string_content
- if has_html_macro?(applied_macros)
- fragment = Markly::Node.new(:inline_html)
- fragment.string_content = formatted
- node.insert_before(fragment)
- node.delete
- else
- node.string_content = formatted
- end
+ fragment = Markly::Node.new(:inline_html)
+ fragment.string_content = formatted
+ node.insert_before(fragment)
+ node.delete
end
def apply_macros_node_html(node, context)
@@ -100,7 +96,7 @@ module WorkPackage::PDFExport::Common::Macro
macro.process_match(Regexp.last_match, matched_string, context)
end
end
- [text, applicable_macros]
+ text
end
def apply_macro_html(html, context)
@@ -111,20 +107,10 @@ module WorkPackage::PDFExport::Common::Macro
doc.to_html
end
- def has_html_macro?(macros)
- macros.any? { |macro| macro.respond_to?(:html_replacement?) && macro.html_replacement? }
- end
-
def apply_macro_html_node(node, context)
if node.text?
- formatted, applied_macros = apply_macro_text(node.content, context)
- if formatted != node.content
- if has_html_macro?(applied_macros)
- node.replace(formatted)
- else
- node.content = formatted
- end
- end
+ formatted = apply_macro_text(node.content, context)
+ node.replace(formatted) if formatted != node.content
elsif PREFORMATTED_BLOCKS.exclude?(node.name)
node.children.each { |child| apply_macro_html_node(child, context) }
end
diff --git a/app/models/work_package/pdf_export/export/markdown.rb b/app/models/work_package/pdf_export/export/markdown.rb
index 95d7e3a863a..da5d05213a4 100644
--- a/app/models/work_package/pdf_export/export/markdown.rb
+++ b/app/models/work_package/pdf_export/export/markdown.rb
@@ -173,6 +173,8 @@ module WorkPackage::PDFExport::Export::Markdown
end
def write_markdown!(markdown, styling_yml)
+ return if markdown.blank?
+
markdown_writer(styling_yml)
.draw_markdown(markdown, pdf, ->(src) {
with_images? ? attachment_image_filepath(src) : nil
diff --git a/app/models/work_package/pdf_export/export/wp/attributes.rb b/app/models/work_package/pdf_export/export/wp/attributes.rb
index 255b7c1acc4..2baa34266b9 100644
--- a/app/models/work_package/pdf_export/export/wp/attributes.rb
+++ b/app/models/work_package/pdf_export/export/wp/attributes.rb
@@ -241,8 +241,13 @@ module WorkPackage::PDFExport::Export::Wp::Attributes
]
end
+ def get_link_cell(custom_url)
+ make_link_href_cell(custom_url.href, custom_url.href)
+ end
+
def get_column_value_cell(work_package, column_name)
value = get_column_value(work_package, column_name)
+ return get_link_cell(value) if value.is_a?(::Exports::Formatters::LinkFormatter)
return get_id_column_cell(work_package, value) if column_name == :id
return get_subject_column_cell(work_package, value) if column_name == :subject
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.rb
index 386df9a46e3..c0487b9a1c4 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
@@ -47,6 +47,9 @@ RSpec.describe WorkPackage::PDFExport::WorkPackageListToPdf do
shared_let(:text_custom_field_b) do
create(:issue_custom_field, :text, types: [type_standard, type_bug], name: "Notes B")
end
+ shared_let(:link_custom_field) do
+ create(:link_wp_custom_field, :link, types: [type_standard, type_bug], name: "My Link")
+ end
shared_let(:custom_value_first) do
create(:work_package_custom_value,
custom_field: list_custom_field,
@@ -57,7 +60,7 @@ RSpec.describe WorkPackage::PDFExport::WorkPackageListToPdf do
create(:project,
name: "Foo Bla. Report No. 4/2021 with/for Case 42",
types:,
- work_package_custom_fields: [list_custom_field, text_custom_field_a, text_custom_field_b])
+ work_package_custom_fields: [list_custom_field, text_custom_field_a, text_custom_field_b, link_custom_field])
end
shared_let(:user) do
create(:user,
@@ -83,7 +86,8 @@ RSpec.describe WorkPackage::PDFExport::WorkPackageListToPdf do
list_custom_field.attribute_name => [
list_custom_field.value_of("Foo"),
list_custom_field.value_of("Bar")
- ])
+ ],
+ link_custom_field.attribute_name => "https://example.com")
end
shared_let(:work_package_child) do
create(:work_package,
@@ -98,7 +102,8 @@ RSpec.describe WorkPackage::PDFExport::WorkPackageListToPdf do
description: "This is work package 2",
text_custom_field_a.attribute_name => "Rich text 2.A",
text_custom_field_b.attribute_name => "Rich text 2.B",
- list_custom_field.attribute_name => list_custom_field.value_of("Foo"))
+ list_custom_field.attribute_name => list_custom_field.value_of("Foo"),
+ link_custom_field.attribute_name => "https://example.com")
end
let(:query_attributes) { {} }
let!(:query) do
@@ -118,7 +123,7 @@ RSpec.describe WorkPackage::PDFExport::WorkPackageListToPdf do
export.export!
end
end
- let(:column_names) { %w[id subject status story_points done_ratio] }
+ let(:column_names) { %W[id subject status story_points done_ratio #{link_custom_field.column_name}] }
def work_packages_sum
work_package_parent.story_points + work_package_child.story_points
@@ -130,7 +135,8 @@ RSpec.describe WorkPackage::PDFExport::WorkPackageListToPdf do
work_package.subject,
work_package.status.name,
work_package.story_points.to_s,
- work_package_done_ratio(work_package)
+ work_package_done_ratio(work_package),
+ "https://example.com"
]
end
@@ -144,7 +150,8 @@ RSpec.describe WorkPackage::PDFExport::WorkPackageListToPdf do
column_title(:id), work_package.id.to_s,
column_title(:status), work_package.status.name,
column_title(:story_points), work_package.story_points.to_s,
- column_title(:done_ratio), work_package_done_ratio(work_package)
+ column_title(:done_ratio), work_package_done_ratio(work_package),
+ "My Link", "https://example.com"
]
ltfs.each do |ltf|
case ltf
@@ -347,49 +354,54 @@ RSpec.describe WorkPackage::PDFExport::WorkPackageListToPdf do
end
end
- describe "grouped with sums" do
- let(:query_attributes) { { display_sums: true, group_by: "type" } }
+ describe "grouped" do
+ let(:long_text_fields) { [] }
+ let(:options) { { pdf_export_type: "report", long_text_fields: "" } }
- it "contains correct data" do
- expect(pdf_strings).to eq [
- *cover_page_content,
- query.name,
- "1.", "2", work_package_parent.subject,
- "2.", "2", work_package_child.subject,
- "1/2", export_date_formatted, query.name,
- I18n.t("js.work_packages.tabs.overview"),
- column_title(:type), column_title(:story_points), column_title(:done_ratio),
- work_package_parent.type.name, work_package_parent.story_points.to_s, "25%",
- work_package_child.type.name, work_package_child.story_points.to_s, "50%",
- I18n.t("js.label_sum"), work_packages_sum.to_s, "38%",
- *work_package_details(work_package_parent, "1", long_text_fields),
- *work_package_details(work_package_child, "2", long_text_fields),
- "2/2", export_date_formatted, query.name
- ].join(" ")
+ describe "by type with sums" do
+ let(:query_attributes) { { display_sums: true, group_by: "type" } }
+
+ it "contains correct data" do
+ expect(pdf_strings).to eq [
+ *cover_page_content,
+ query.name,
+ "1.", "2", work_package_parent.subject,
+ "2.", "2", work_package_child.subject,
+ "1/2", export_date_formatted, query.name,
+ I18n.t("js.work_packages.tabs.overview"),
+ column_title(:type), column_title(:story_points), column_title(:done_ratio),
+ work_package_parent.type.name, work_package_parent.story_points.to_s, "25%",
+ work_package_child.type.name, work_package_child.story_points.to_s, "50%",
+ I18n.t("js.label_sum"), work_packages_sum.to_s, "38%",
+ *work_package_details(work_package_parent, "1", long_text_fields),
+ *work_package_details(work_package_child, "2", long_text_fields),
+ "2/2", export_date_formatted, query.name
+ ].join(" ")
+ end
end
- end
-
- describe "grouped by a custom field with sums" do
- let(:query_attributes) { { display_sums: true, group_by: list_custom_field.column_name } }
-
- it "contains correct data" do
- expect(pdf_strings).to eq [
- *cover_page_content,
- query.name,
- "1.", "2", work_package_child.subject,
- "2.", "2", work_package_parent.subject,
- "1/2", export_date_formatted, query.name,
- I18n.t("js.work_packages.tabs.overview"),
- list_custom_field.name, column_title(:story_points), column_title(:done_ratio),
- "Foo", work_package_child.story_points.to_s, "50%",
- "Foo, Bar", work_package_parent.story_points.to_s, "25%",
- I18n.t("js.label_sum"), work_packages_sum.to_s, "38%",
-
- *work_package_details(work_package_child, "1", long_text_fields),
- *work_package_details(work_package_parent, "2", long_text_fields),
- "2/2", export_date_formatted, query.name
- ].join(" ")
+ describe "by a custom field with sums" do
+ let(:query_attributes) { { display_sums: true, group_by: list_custom_field.column_name } }
+
+ it "contains correct data" do
+ expect(pdf_strings).to eq [
+ *cover_page_content,
+ query.name,
+ "1.", "2", work_package_child.subject,
+ "2.", "2", work_package_parent.subject,
+ "1/2", export_date_formatted, query.name,
+ I18n.t("js.work_packages.tabs.overview"),
+ list_custom_field.name, column_title(:story_points), column_title(:done_ratio),
+
+ "Foo", work_package_child.story_points.to_s, "50%",
+ "Foo, Bar", work_package_parent.story_points.to_s, "25%",
+ I18n.t("js.label_sum"), work_packages_sum.to_s, "38%",
+
+ *work_package_details(work_package_child, "1", long_text_fields),
+ *work_package_details(work_package_parent, "2", long_text_fields),
+ "2/2", export_date_formatted, query.name
+ ].join(" ")
+ end
end
end
end
diff --git a/spec/models/work_packages/pdf_export/work_package_to_pdf_spec.rb b/spec/models/work_packages/pdf_export/work_package_to_pdf_spec.rb
index 1f1c9ba2060..8568612fe5e 100644
--- a/spec/models/work_packages/pdf_export/work_package_to_pdf_spec.rb
+++ b/spec/models/work_packages/pdf_export/work_package_to_pdf_spec.rb
@@ -34,7 +34,8 @@ RSpec.describe WorkPackage::PDFExport::WorkPackageToPdf do
include Redmine::I18n
include PDFExportSpecUtils
let(:type) do
- create(:type_bug, custom_fields: [cf_long_text, cf_empty_long_text, cf_disabled_in_project, cf_global_bool])
+ create(:type_bug,
+ custom_fields: [cf_long_text, cf_empty_long_text, cf_disabled_in_project, cf_global_bool, cf_link])
end
let(:parent_project) do
create(:project, name: "Parent project")
@@ -65,10 +66,10 @@ RSpec.describe WorkPackage::PDFExport::WorkPackageToPdf do
project_custom_field_bool.id => true,
project_custom_field_long_text.id => "foo"
},
- work_package_custom_fields: [cf_long_text, cf_empty_long_text, cf_disabled_in_project, cf_global_bool],
+ work_package_custom_fields: [cf_long_text, cf_empty_long_text, cf_disabled_in_project, cf_global_bool, cf_link],
# cf_disabled_in_project.id not included == disabled
- work_package_custom_field_ids: [cf_long_text.id, cf_empty_long_text.id, cf_global_bool.id])
+ work_package_custom_field_ids: [cf_long_text.id, cf_empty_long_text.id, cf_global_bool.id, cf_link.id])
end
let(:forbidden_project) do
create(:project,
@@ -80,10 +81,10 @@ RSpec.describe WorkPackage::PDFExport::WorkPackageToPdf do
status_code: "on_track",
active: true,
parent: parent_project,
- work_package_custom_fields: [cf_long_text, cf_empty_long_text, cf_disabled_in_project, cf_global_bool],
+ work_package_custom_fields: [cf_long_text, cf_empty_long_text, cf_disabled_in_project, cf_global_bool, cf_link],
# cf_disabled_in_project.id not included == disabled
- work_package_custom_field_ids: [cf_long_text.id, cf_empty_long_text.id, cf_global_bool.id])
+ work_package_custom_field_ids: [cf_long_text.id, cf_empty_long_text.id, cf_global_bool.id, cf_link.id])
end
let(:user) do
create(:user,
@@ -107,6 +108,9 @@ RSpec.describe WorkPackage::PDFExport::WorkPackageToPdf do
let(:cf_long_text) do
create(:issue_custom_field, :text, name: "Work Package Custom Field Long Text")
end
+ let(:cf_link) do
+ create(:link_wp_custom_field, :link, name: "My Link")
+ end
let(:cf_empty_long_text) do
create(:issue_custom_field, :text, name: "Empty Work Package Custom Field Long Text")
end
@@ -169,7 +173,8 @@ RSpec.describe WorkPackage::PDFExport::WorkPackageToPdf do
cf_long_text.id => cf_long_text_description,
cf_empty_long_text.id => cf_empty_long_text_description,
cf_disabled_in_project.id => "6.25",
- cf_global_bool.id => true
+ cf_global_bool.id => true,
+ cf_link.id => "https://example.com"
}).tap do |wp|
allow(wp)
.to receive(:attachments)
@@ -230,9 +235,10 @@ RSpec.describe WorkPackage::PDFExport::WorkPackageToPdf do
"Project phase",
"Date", "05/30/2024 - 03/13/2025",
"Other",
- "Work Package Custom Field Boolean", "Yes",
- "Empty Work Package Custom Field Long Text",
"Work Package Custom Field Long Text", "foo faa",
+ "Empty Work Package Custom Field Long Text",
+ "Work Package Custom Field Boolean", "Yes",
+ "My Link", "https://example.com",
"Costs",
"Spent units", "Labor costs", "Unit costs", "Overall costs", "Budget"
]
@@ -339,6 +345,7 @@ RSpec.describe WorkPackage::PDFExport::WorkPackageToPdf do
<tr><td>Custom field rich text</td><td>
workPackageValue:1:"#{cf_long_text.name}"
</td></tr>
+ <tr><td>My link in table</td><td>workPackageValue:"#{cf_link.name}"</td></tr>
<tr><td>No replacement of:</td><td>
<code>workPackageValue:1:assignee</code>
<code>workPackageLabel:assignee</code>
@@ -352,6 +359,8 @@ RSpec.describe WorkPackage::PDFExport::WorkPackageToPdf do
workPackageLabel:assignee
```
+ workPackageValue:"My Link"
+
Work package not found:
workPackageValue:1234567890:assignee
Access denied:
@@ -359,6 +368,24 @@ RSpec.describe WorkPackage::PDFExport::WorkPackageToPdf do
DESCRIPTION
end
+ def expected_description
+ [
+ "Custom field boolean", I18n.t(:general_text_Yes),
+ "Custom field rich text", "[#{I18n.t('export.macro.rich_text_unsupported')}]",
+ "My link in table", "https://example.com",
+ "No replacement of:", "workPackageValue:1:assignee", " ", "workPackageLabel:assignee",
+ "workPackageValue:2:assignee workPackageLabel:assignee",
+ "workPackageValue:3:assignee", "workPackageLabel:assignee",
+ "https://example.com",
+ "Work package not found: ",
+ "[#{I18n.t('export.macro.error', message:
+ I18n.t('export.macro.resource_not_found', resource: 'WorkPackage 1234567890'))}] ",
+ "Access denied: ",
+ "[#{I18n.t('export.macro.error', message:
+ I18n.t('export.macro.resource_not_found', resource: "WorkPackage #{forbidden_work_package.id}"))}]",
+ ]
+ end
+
it "contains resolved attributes and labels" do
# Joining with space for comparison since word wrapping leads to a different array for the same content
result = pdf[:strings].join(" ")
@@ -372,17 +399,7 @@ RSpec.describe WorkPackage::PDFExport::WorkPackageToPdf do
API::Utilities::PropertyNameConverter.to_ar_name(embed[0].to_sym, context: work_package)
), embed[1]]
end,
- "Custom field boolean", I18n.t(:general_text_Yes),
- "Custom field rich text", "[#{I18n.t('export.macro.rich_text_unsupported')}]",
- "No replacement of:", "workPackageValue:1:assignee", " ", "workPackageLabel:assignee",
- "workPackageValue:2:assignee workPackageLabel:assignee",
- "workPackageValue:3:assignee", "workPackageLabel:assignee",
- "Work package not found: ",
- "[#{I18n.t('export.macro.error', message:
- I18n.t('export.macro.resource_not_found', resource: 'WorkPackage 1234567890'))}] ",
- "Access denied: ",
- "[#{I18n.t('export.macro.error', message:
- I18n.t('export.macro.resource_not_found', resource: "WorkPackage #{forbidden_work_package.id}"))}]",
+ *expected_description,
"2", export_date_formatted, project.name
].flatten.join(" ")
expect(result).to eq(expected_result)
diff --git a/spec/support/work_packages/pdf_export.rb b/spec/support/work_packages/pdf_export.rb
index dbc06880c94..407bb80721b 100644
--- a/spec/support/work_packages/pdf_export.rb
+++ b/spec/support/work_packages/pdf_export.rb
@@ -9,6 +9,10 @@ module PDFExportSpecUtils
end
def label_title(column_name)
+ if column_name.start_with?("cf_")
+ id = column_name.delete_prefix("cf_").to_i
+ return ::CustomField.find_by(id:).name
+ end
WorkPackage.human_attribute_name(column_name)
end
end