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 test for WorkPackageEagerLoadingWrapper text formatting; addresses https://github.com/opf/openproject/pull/16542#discussion_r1736049674
as-opa1d5c82a6252
diff --git a/lib/open_project/text_formatting/matchers/attribute_macros.rb b/lib/open_project/text_formatting/matchers/attribute_macros.rbindex 09511d88f34..92aeffe1ae8 100644--- a/lib/open_project/text_formatting/matchers/attribute_macros.rb+++ b/lib/open_project/text_formatting/matchers/attribute_macros.rb@@ -55,7 +55,8 @@ module OpenProject::TextFormattingdef self.work_package_context?(context)# workPackageValue can be used in e.g. wiki and meeting notes without a work package,# relative embedding is not supported in these cases- context[:object].is_a?(WorkPackage) || context[:object].is_a?(API::V3::WorkPackages::WorkPackageEagerLoadingWrapper)+ # work package list view or the work package fullscreen view use the wrapper via API calls, not the WorkPackage model+ context[:object].is_a?(API::V3::WorkPackages::WorkPackageEagerLoadingWrapper) || context[:object].is_a?(WorkPackage)enddef self.work_package_embed?(macro_attributes)diff --git a/spec/lib/open_project/text_formatting/markdown/attribute_macros_spec.rb b/spec/lib/open_project/text_formatting/markdown/attribute_macros_spec.rbindex 476ed7156a0..769f26bcaf6 100644--- a/spec/lib/open_project/text_formatting/markdown/attribute_macros_spec.rb+++ b/spec/lib/open_project/text_formatting/markdown/attribute_macros_spec.rb@@ -29,13 +29,7 @@require "spec_helper"require_relative "expected_markdown"-RSpec.describe OpenProject::TextFormatting,- "Attribute macros" do- include_context "expected markdown modules"- shared_let(:project) { create(:valid_project, id: 4321) }- let(:work_package) { create(:work_package, project:, id: 1234) }- let(:options) { { project:, object: work_package } }-+RSpec.shared_examples_for "resolving macros" dodescribe "attribute label macros" doit_behaves_like "format_text produces" dolet(:raw) do@@ -134,3 +128,26 @@ RSpec.describe OpenProject::TextFormatting,endendend++RSpec.describe OpenProject::TextFormatting, "Attribute macros" do+ include_context "expected markdown modules"+ shared_let(:project) { create(:valid_project, id: 4321) }+ let(:work_package) { create(:work_package, project:, id: 1234) }++ context "with work package" do+ it_behaves_like "resolving macros" do+ let(:options) { { project:, object: work_package } }+ end+ end++ context "with eager loading work package wrapper" do+ it_behaves_like "resolving macros" do+ let(:options) do+ {+ project:,+ object: API::V3::WorkPackages::WorkPackageEagerLoadingWrapper.wrap_one(work_package, nil)+ }+ end+ end+ end+end