diff --git a/app/assets/javascripts/discourse/templates/featured_topics.js.handlebars b/app/assets/javascripts/discourse/templates/featured_topics.js.handlebars index fb5ee8d5c35..685bfb51b25 100644 --- a/app/assets/javascripts/discourse/templates/featured_topics.js.handlebars +++ b/app/assets/javascripts/discourse/templates/featured_topics.js.handlebars @@ -31,7 +31,7 @@ {{#if hasExcerpt}}
- {{excerpt}} + {{{excerpt}}} {{#if excerptTruncated}} {{#unless canClearPin}}{{i18n read_more}}{{/unless}} {{/if}} diff --git a/app/models/category_featured_topic.rb b/app/models/category_featured_topic.rb index 2bd61439180..32165840d57 100644 --- a/app/models/category_featured_topic.rb +++ b/app/models/category_featured_topic.rb @@ -17,7 +17,13 @@ class CategoryFeaturedTopic < ActiveRecord::Base CategoryFeaturedTopic.transaction do CategoryFeaturedTopic.delete_all(category_id: c.id) - query = TopicQuery.new(nil, per_page: SiteSetting.category_featured_topics) + + # fake an admin + admin = User.new + admin.admin = true + admin.id = -1 + + query = TopicQuery.new(admin, per_page: SiteSetting.category_featured_topics) results = query.list_category(c) if results.present? results.topic_ids.each_with_index do |topic_id, idx| diff --git a/app/serializers/listable_topic_serializer.rb b/app/serializers/listable_topic_serializer.rb index b48448a24a4..c5718b31de9 100644 --- a/app/serializers/listable_topic_serializer.rb +++ b/app/serializers/listable_topic_serializer.rb @@ -56,6 +56,7 @@ class ListableTopicSerializer < BasicTopicSerializer end def excerpt + # excerpt should be hoisted into topic, this is an N+1 query ... yuck object.posts.by_post_number.first.try(:excerpt, 220, strip_links: true) || nil end diff --git a/spec/models/category_featured_topic_spec.rb b/spec/models/category_featured_topic_spec.rb index c327d66c0f1..f40577bbf00 100644 --- a/spec/models/category_featured_topic_spec.rb +++ b/spec/models/category_featured_topic_spec.rb @@ -5,5 +5,23 @@ describe CategoryFeaturedTopic do it { should belong_to :category } it { should belong_to :topic } + it "should feature topics for a secure category" do + + # so much dancing, I am thinking fixures make sense here. + user = Fabricate(:user) + user.change_trust_level!(:basic) + + category = Fabricate(:category) + category.deny(:all) + category.allow(Group[:trust_level_1]) + category.save + + post = PostCreator.create(user, raw: "this is my new post 123 post", title: "hello world") + + CategoryFeaturedTopic.feature_topics_for(category) + CategoryFeaturedTopic.count.should == 1 + + end + end