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
add tests with another work package referenced by ID
as-op78d97f161d81
diff --git a/spec/models/work_package/pdf_export/common/macro_spec.rb b/spec/models/work_package/pdf_export/common/macro_spec.rbindex 58f95d56c73..9f6834cd654 100644--- a/spec/models/work_package/pdf_export/common/macro_spec.rb+++ b/spec/models/work_package/pdf_export/common/macro_spec.rb@@ -67,13 +67,25 @@ RSpec.describe WorkPackage::PDFExport::Common::Macro do:work_package,subject: "Work package 1",type: type_task,- status: create(:status, name: "In Progress"), project: project,+ status: create(:status, name: "In Progress"),+ project: project,custom_field_values: {custom_field.id => "Custom value 1",formatted_custom_field.id => "**Formatted** _text_ content"})end+ shared_let(:other_work_package) do+ create(+ :work_package,+ subject: "Work package 2",+ project: project,+ type: type_task,+ custom_field_values: {+ custom_field.id => "Custom value 2"+ }+ )+ endshared_let(:formatter) { Class.new { extend WorkPackage::PDFExport::Common::Macro } }let(:additional_permissions) { [] }let(:user) do@@ -119,12 +131,12 @@ RSpec.describe WorkPackage::PDFExport::Common::Macro doit "loops the tag through" do# note: escaped backslash in the tag text for correct markdown renderingexpect(formatted).to eq(- "<mention class=\"mention\" data-id=\"#{- work_package.id- }\" data-type=\"work_package\" data-text=\"##{- work_package.id- }\">\\##{work_package.id}</mention>"- )+ "<mention class=\"mention\" data-id=\"#{+ work_package.id+ }\" data-type=\"work_package\" data-text=\"##{+ work_package.id+ }\">\\##{work_package.id}</mention>"+ )endend@@ -178,6 +190,14 @@ RSpec.describe WorkPackage::PDFExport::Common::Macro doendend+ describe "withh another work package ID and attribute" do+ let(:markdown) { "workPackageValue:#{other_work_package.id}:subject" }++ it "outputs the attribute value for the specified work package" do+ expect(formatted).to eq("Work package 2")+ end+ end+describe "with non-existent work package ID" dolet(:markdown) { "workPackageValue:999:subject" }@@ -246,6 +266,14 @@ RSpec.describe WorkPackage::PDFExport::Common::Macro doendend+ describe "with another work package ID and custom field" do+ let(:markdown) { "workPackageValue:#{other_work_package.id}:\"Custom Field 1\"" }++ it "outputs the custom field value for the specified work package" do+ expect(formatted).to eq("Custom value 2")+ end+ end+describe "with formatted custom field" dolet(:markdown) { 'workPackageValue:"Custom Formatted Field"' }@@ -270,6 +298,14 @@ RSpec.describe WorkPackage::PDFExport::Common::Macro doendend+ describe "with another work package id and a non-existent attribute" do+ let(:markdown) { "workPackageValue:#{other_work_package.id}:nonexistent_attribute" }++ it "outputs an empty value" do+ expect(formatted).to eq(" ")+ end+ end+describe "with markdown formatting" dolet(:markdown) { "**workPackageValue:subject**" }