diff --git a/app/models/work_package/exports/macros/attributes.rb b/app/models/work_package/exports/macros/attributes.rb index fa979b5e4d51..4885c9ad355d 100644 --- a/app/models/work_package/exports/macros/attributes.rb +++ b/app/models/work_package/exports/macros/attributes.rb @@ -114,6 +114,7 @@ def self.resolve_project_match(id, type, attribute, user) return msg_macro_error(I18n.t("export.macro.model_not_found", model: type)) unless type == "value" project = Project.visible(user).find_by(id:) + project = Project.visible(user).find_by(identifier: id) if project.nil? if project.nil? return msg_macro_error(I18n.t("export.macro.resource_not_found", resource: "#{Project.name} #{id}")) end diff --git a/app/models/work_package/pdf_export/markdown_field.rb b/app/models/work_package/pdf_export/markdown_field.rb index b478d14278ab..f5d45baa1dd5 100644 --- a/app/models/work_package/pdf_export/markdown_field.rb +++ b/app/models/work_package/pdf_export/markdown_field.rb @@ -54,9 +54,9 @@ def apply_macros(markdown, work_package, formatter) document = Markly.parse(markdown) document.walk do |node| if node.type == :html - node.string_content = apply_macro_html(node.string_content, work_package, formatter) + node.string_content = apply_macro_html(node.string_content, work_package, formatter) || node.string_content elsif node.type == :text - node.string_content = apply_macro_text(node.string_content, work_package, formatter) + node.string_content = apply_macro_text(node.string_content, work_package, formatter) || node.string_content end end document.to_markdown @@ -72,6 +72,8 @@ def apply_macro_text(text, work_package, formatter) end def apply_macro_html(html, work_package, formatter) + return html unless formatter.applicable?(html) + doc = Nokogiri::HTML.fragment(html) apply_macro_html_node(doc, work_package, formatter) doc.to_html 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 9a703b1fb544..6078c2c63782 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 @@ -72,6 +72,7 @@ name: "Forbidden project", types: [type], id: 666, + identifier: "forbidden-project", public: false, status_code: "on_track", active: true, @@ -370,10 +371,15 @@ def get_column_value(column_name) projectLabel:status ``` + Project by identifier: + projectValue:"#{project.identifier}":active + Project not found: projectValue:1234567890:active Access denied: projectValue:#{forbidden_project.id}:active + Access denied by identifier: + projectValue:"#{forbidden_project.identifier}":active DESCRIPTION end it "contains resolved attributes and labels" do @@ -397,14 +403,16 @@ def get_column_value(column_name) "1", export_time_formatted, project.name, + "Project by identifier:", " ", I18n.t(:general_text_Yes), "Project not found: ", "[#{I18n.t('export.macro.error', message: I18n.t('export.macro.resource_not_found', resource: "Project 1234567890"))}] ", "Access denied: ", "[#{I18n.t('export.macro.error', message: - I18n.t('export.macro.resource_not_found', resource: "Project #{forbidden_project.id}"))}]", + I18n.t('export.macro.resource_not_found', resource: "Project #{forbidden_project.id}"))}] ", + "Access denied by identifier:", " ", "[Macro error, resource not found: Project", "forbidden-project]", - "2", export_time_formatted, project.name, + "2", export_time_formatted, project.name, ].flatten expect(result.join(" ")).to eq(expected_result.join(" ")) end