Skip to content

A platform for community discussion. Free, open, simple.

FIX: Hashtag error in PrettyText when processing email (#22680)

Martin Brennan3be9e6c97e2d
diff --git a/lib/pretty_text/helpers.rb b/lib/pretty_text/helpers.rb
index fe50d71c054..5f48b28bbdc 100644
--- a/lib/pretty_text/helpers.rb
+++ b/lib/pretty_text/helpers.rb
@@ -125,6 +125,11 @@ module PrettyText
cooking_user = User.find(cooking_user_id)
end
+ types_in_priority_order =
+ types_in_priority_order.select do |type|
+ HashtagAutocompleteService.data_source_types.include?(type)
+ end
+
result =
HashtagAutocompleteService.new(Guardian.new(cooking_user)).lookup(
[slug],
diff --git a/spec/lib/pretty_text/helpers_spec.rb b/spec/lib/pretty_text/helpers_spec.rb
index ff14ee704e0..0244da8a3b4 100644
--- a/spec/lib/pretty_text/helpers_spec.rb
+++ b/spec/lib/pretty_text/helpers_spec.rb
@@ -163,6 +163,13 @@ RSpec.describe PrettyText::Helpers do
)
end
+ it "does not return any results for disabled types" do
+ SiteSetting.tagging_enabled = false
+ expect(
+ PrettyText::Helpers.hashtag_lookup("somecooltag::tag", user.id, %w[category tag]),
+ ).to eq(nil)
+ end
+
it "returns nil when no tag or category that matches exists" do
expect(PrettyText::Helpers.hashtag_lookup("blah", user.id, %w[category tag])).to eq(nil)
end