Merge pull request #1407 from einarj/extract_fake_admin_method

Extracted a fake_admin method
This commit is contained in:
Robin Ward 2013-09-04 07:59:03 -07:00
commit 1a6170a47c

View file

@ -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