FIX: Use Discourse.system_user when we need a placeholder admin (#9781)

FIX: Use Discourse.system_user when we need a placeholder admin (#9781)

diff --git a/app/models/category_featured_topic.rb b/app/models/category_featured_topic.rb
index cfad73d..2e454ef 100644
--- a/app/models/category_featured_topic.rb
+++ b/app/models/category_featured_topic.rb
@@ -59,7 +59,7 @@ class CategoryFeaturedTopic < ActiveRecord::Base
     # no featured topics (all the previous 2x topics are only visible to admins)
 
     # Add topics, even if they're in secured categories or invisible
-    query = TopicQuery.new(CategoryFeaturedTopic.fake_admin, query_opts)
+    query = TopicQuery.new(Discourse.system_user, query_opts)
     results = query.list_category_topic_ids(c).uniq
 
     # Add some topics that are visible to everyone:
@@ -81,15 +81,6 @@ class CategoryFeaturedTopic < ActiveRecord::Base
       end
     end
   end
-
-  def self.fake_admin
-    # fake an admin
-    admin = User.new
-    admin.admin = true
-    admin.id = -1
-    admin
-  end
-
 end
 
 # == Schema Information
diff --git a/app/services/random_topic_selector.rb b/app/services/random_topic_selector.rb
index 4a89646..467b4db 100644
--- a/app/services/random_topic_selector.rb
+++ b/app/services/random_topic_selector.rb
@@ -25,7 +25,7 @@ class RandomTopicSelector
       end
 
       # don't leak private categories into the "everything" group
-      options[:guardian] = Guardian.new(CategoryFeaturedTopic.fake_admin)
+      options[:guardian] = Guardian.new(Discourse.system_user)
     end
 
     query = TopicQuery.new(nil, options)

GitHub sha: 52278ce6

This commit appears in #9781 which was approved by eviltrout. It was merged by SamSaffron.