diff --git a/app/models/work_package/semantic_identifier.rb b/app/models/work_package/semantic_identifier.rb index b8b728a9069..43c9769d59e 100644 --- a/app/models/work_package/semantic_identifier.rb +++ b/app/models/work_package/semantic_identifier.rb @@ -124,8 +124,8 @@ module WorkPackage::SemanticIdentifier # Returns formatted value for inline UI display. # * Semantic mode: "PROJ-42" (no prefix — self-describing) # * Classic mode: "#42" (hash-prefixed) - def self.with_hash_prefix(value) - value.is_a?(String) && value.match?(/[A-Za-z]/) ? value : "##{value}" + def self.format_display_id(display_id) + display_id.is_a?(String) && display_id.match?(/[A-Za-z]/) ? display_id : "##{display_id}" end # Returns the user-facing identifier for this work package. @@ -141,7 +141,7 @@ module WorkPackage::SemanticIdentifier # Semantic mode: "PROJ-42" (no prefix — self-describing) # Classic mode: "#42" (hash-prefixed) def formatted_id - WorkPackage::SemanticIdentifier.with_hash_prefix(display_id) + WorkPackage::SemanticIdentifier.format_display_id(display_id) end # Override ActiveRecord's default `to_param` so Rails URL helpers diff --git a/lib/open_project/text_formatting/matchers/link_handlers/work_packages.rb b/lib/open_project/text_formatting/matchers/link_handlers/work_packages.rb index 99a275fef29..8d2c856720c 100644 --- a/lib/open_project/text_formatting/matchers/link_handlers/work_packages.rb +++ b/lib/open_project/text_formatting/matchers/link_handlers/work_packages.rb @@ -101,7 +101,7 @@ module OpenProject::TextFormatting::Matchers def render_work_package_macro(work_package:, fallback_id:, detailed: false) id = work_package&.id || fallback_id display_id = work_package&.display_id || fallback_id - label = WorkPackage::SemanticIdentifier.with_hash_prefix(display_id) + label = WorkPackage::SemanticIdentifier.format_display_id(display_id) return label if text_only?(work_package) return render_static_work_package_macro(work_package, label, detailed:) if context[:static_html] diff --git a/spec/models/work_package/semantic_identifier_spec.rb b/spec/models/work_package/semantic_identifier_spec.rb index cbd8a35731e..c07349d42c1 100644 --- a/spec/models/work_package/semantic_identifier_spec.rb +++ b/spec/models/work_package/semantic_identifier_spec.rb @@ -606,17 +606,17 @@ RSpec.describe WorkPackage::SemanticIdentifier do end end - describe ".format" do + describe ".format_display_id" do it "returns the semantic identifier unchanged when it carries letters" do - expect(described_class.format("MYPROJ-1")).to eq("MYPROJ-1") + expect(described_class.format_display_id("MYPROJ-1")).to eq("MYPROJ-1") end it "hash-prefixes a numeric integer" do - expect(described_class.format(42)).to eq("#42") + expect(described_class.format_display_id(42)).to eq("#42") end it "hash-prefixes a numeric string" do - expect(described_class.format("42")).to eq("#42") + expect(described_class.format_display_id("42")).to eq("#42") end end