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 project referenced by ID
as-op5a9a0f95e82c
diff --git a/spec/models/work_package/pdf_export/common/macro_spec.rb b/spec/models/work_package/pdf_export/common/macro_spec.rbindex 9f6834cd654..e32a5387cb8 100644--- a/spec/models/work_package/pdf_export/common/macro_spec.rb+++ b/spec/models/work_package/pdf_export/common/macro_spec.rb@@ -62,6 +62,15 @@ RSpec.describe WorkPackage::PDFExport::Common::Macro docustom_field_values: { project_custom_field.id => "Project custom value 1" })end+ shared_let(:other_project) do+ create(+ :project,+ name: "Other Project",+ 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 2" }+ )+ endshared_let(:work_package) docreate(:work_package,@@ -79,7 +88,7 @@ RSpec.describe WorkPackage::PDFExport::Common::Macro docreate(:work_package,subject: "Work package 2",- project: project,+ project: other_project,type: type_task,custom_field_values: {custom_field.id => "Custom value 2"@@ -92,7 +101,8 @@ RSpec.describe WorkPackage::PDFExport::Common::Macro docreate(:user,member_with_permissions: {- project => %i[view_work_packages view_project_attributes view_project] + additional_permissions+ project => %i[view_work_packages view_project_attributes view_project] + additional_permissions,+ other_project => %i[view_work_packages view_project_attributes view_project] + additional_permissions})end@@ -131,12 +141,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=\"#{+ "<mention class=\"mention\" data-id=\"#{work_package.id}\" data-type=\"work_package\" data-text=\"##{work_package.id}\">\\##{work_package.id}</mention>"- )+ )endend@@ -424,6 +434,14 @@ RSpec.describe WorkPackage::PDFExport::Common::Macro doendend+ describe "with other project ID and attribute" do+ let(:markdown) { "projectValue:#{other_project.id}:name" }++ it "outputs the attribute value for the specified project" do+ expect(formatted).to eq(other_project.name)+ end+ end+describe "with specific project identifier and attribute" dolet(:markdown) { "projectValue:\"#{project.identifier}\":name" }@@ -432,6 +450,14 @@ RSpec.describe WorkPackage::PDFExport::Common::Macro doendend+ describe "with other project identifier and attribute" do+ let(:markdown) { "projectValue:\"#{other_project.identifier}\":name" }++ it "outputs the attribute value for the specified project" do+ expect(formatted).to eq(other_project.name)+ end+ end+describe "with non-existent project ID" dolet(:markdown) { "projectValue:999:name" }@@ -464,6 +490,14 @@ RSpec.describe WorkPackage::PDFExport::Common::Macro doendend+ describe "with other project ID and custom field" do+ let(:markdown) { "projectValue:#{other_project.id}:\"Project Custom Field 1\"" }++ it "outputs the custom field value for the specified project" do+ expect(formatted).to eq("Project custom value 2")+ end+ end+describe "with non-existent attribute" dolet(:markdown) { "projectValue:nonexistent_attribute" }