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

add test for unsupported formatted Custom Field

as-opd75e6a50b6d8
diff --git a/spec/models/work_package/pdf_export/common/macro_spec.rb b/spec/models/work_package/pdf_export/common/macro_spec.rb
index 427c7fad596..58f95d56c73 100644
--- a/spec/models/work_package/pdf_export/common/macro_spec.rb
+++ b/spec/models/work_package/pdf_export/common/macro_spec.rb
@@ -40,6 +40,15 @@ RSpec.describe WorkPackage::PDFExport::Common::Macro do
types: [type_task]
)
end
+ shared_let(:formatted_custom_field) do
+ create(
+ :work_package_custom_field,
+ name: "Custom Formatted Field",
+ field_format: "text",
+ is_for_all: true,
+ types: [type_task]
+ )
+ end
shared_let(:project_custom_field_section) { create(:project_custom_field_section) }
shared_let(:project_custom_field) do
create(:string_project_custom_field, name: "Project Custom Field 1", project_custom_field_section:)
@@ -48,7 +57,7 @@ RSpec.describe WorkPackage::PDFExport::Common::Macro do
create(
:project,
status_code: "on_track",
- work_package_custom_fields: [custom_field],
+ work_package_custom_fields: [custom_field, formatted_custom_field],
project_custom_fields: [project_custom_field],
custom_field_values: { project_custom_field.id => "Project custom value 1" }
)
@@ -59,7 +68,10 @@ RSpec.describe WorkPackage::PDFExport::Common::Macro do
subject: "Work package 1",
type: type_task,
status: create(:status, name: "In Progress"), project: project,
- custom_field_values: { custom_field.id => "Custom value 1" }
+ custom_field_values: {
+ custom_field.id => "Custom value 1",
+ formatted_custom_field.id => "**Formatted** _text_ content"
+ }
)
end
shared_let(:formatter) { Class.new { extend WorkPackage::PDFExport::Common::Macro } }
@@ -234,6 +246,22 @@ RSpec.describe WorkPackage::PDFExport::Common::Macro do
end
end
+ describe "with formatted custom field" do
+ let(:markdown) { 'workPackageValue:"Custom Formatted Field"' }
+
+ it "outputs an error message for rich text" do
+ expect(formatted).to include(I18n.t("export.macro.rich_text_unsupported"))
+ end
+ end
+
+ describe "with specific work package ID and formatted custom field" do
+ let(:markdown) { "workPackageValue:#{work_package.id}:\"Custom Formatted Field\"" }
+
+ it "outputs an error message for rich text" do
+ expect(formatted).to include(I18n.t("export.macro.rich_text_unsupported"))
+ end
+ end
+
describe "with non-existent attribute" do
let(:markdown) { "workPackageValue:nonexistent_attribute" }