Skip to content

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

FIX: Staged users should not be mentionable.

Guo Xiang Tan672e95bcb4c7
diff --git a/lib/pretty_text.rb b/lib/pretty_text.rb
index d30a4f84ac5..e7682f9010a 100644
--- a/lib/pretty_text.rb
+++ b/lib/pretty_text.rb
@@ -460,7 +460,7 @@ module PrettyText
:user_type AS type,
username_lower AS name
FROM users
- WHERE username_lower IN (:names)
+ WHERE username_lower IN (:names) AND staged = false
)
UNION
(
diff --git a/spec/components/pretty_text_spec.rb b/spec/components/pretty_text_spec.rb
index b3de8d0a210..6655e085310 100644
--- a/spec/components/pretty_text_spec.rb
+++ b/spec/components/pretty_text_spec.rb
@@ -241,6 +241,14 @@ describe PrettyText do
end
end
+ it 'does not mention staged users' do
+ user = Fabricate(:user, staged: true)
+
+ expect(PrettyText.cook("something @#{user.username} something")).to eq(
+ %Q|<p>something <span class="mention">@#{user.username}</span> something</p>|
+ )
+ end
+
describe 'when mentions are disabled' do
before do
SiteSetting.enable_mentions = false