diff --git a/lib/open_project/text_formatting/matchers/attribute_macros.rb b/lib/open_project/text_formatting/matchers/attribute_macros.rb index 09511d88f34a..92aeffe1ae81 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 @@ def self.applicable?(content) def 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) end def 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.rb index 476ed7156a04..769f26bcaf6c 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" do describe "attribute label macros" do it_behaves_like "format_text produces" do let(:raw) do @@ -134,3 +128,26 @@ end end end + +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