mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 23:58:31 -05:00
Merge pull request #1407 from einarj/extract_fake_admin_method
Extracted a fake_admin method
This commit is contained in:
commit
1a6170a47c
1 changed files with 10 additions and 6 deletions
|
@ -18,12 +18,7 @@ class CategoryFeaturedTopic < ActiveRecord::Base
|
|||
CategoryFeaturedTopic.transaction do
|
||||
CategoryFeaturedTopic.delete_all(category_id: c.id)
|
||||
|
||||
# fake an admin
|
||||
admin = User.new
|
||||
admin.admin = true
|
||||
admin.id = -1
|
||||
|
||||
query = TopicQuery.new(admin, per_page: SiteSetting.category_featured_topics, except_topic_id: c.topic_id, visible: true)
|
||||
query = TopicQuery.new(self.fake_admin, per_page: SiteSetting.category_featured_topics, except_topic_id: c.topic_id, visible: true)
|
||||
results = query.list_category(c)
|
||||
if results.present?
|
||||
results.topic_ids.each_with_index do |topic_id, idx|
|
||||
|
@ -33,6 +28,15 @@ class CategoryFeaturedTopic < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
private
|
||||
def self.fake_admin
|
||||
# fake an admin
|
||||
admin = User.new
|
||||
admin.admin = true
|
||||
admin.id = -1
|
||||
admin
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# == Schema Information
|
||||
|
|
Loading…
Reference in a new issue