FIX: Staged users should not be mentionable

FIX: Staged users should not be mentionable.

From 672e95bcb4c751734de12632e10404f410851673 Mon Sep 17 00:00:00 2001
From: Guo Xiang Tan <tgx_world@hotmail.com>
Date: Thu, 22 Nov 2018 15:00:46 +0800
Subject: [PATCH] FIX: Staged users should not be mentionable.


diff --git a/lib/pretty_text.rb b/lib/pretty_text.rb
index d30a4f8..e7682f9 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 b3de8d0..6655e08 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

GitHub

1 Like