mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 09:36:19 -05:00
fix encoding for category excerpt
fix missing secure category topics in categories page
This commit is contained in:
parent
5e305eaf0a
commit
9a57aaaaa9
4 changed files with 27 additions and 2 deletions
|
@ -31,7 +31,7 @@
|
|||
|
||||
{{#if hasExcerpt}}
|
||||
<div class="topic-excerpt">
|
||||
{{excerpt}}
|
||||
{{{excerpt}}}
|
||||
{{#if excerptTruncated}}
|
||||
{{#unless canClearPin}}<a href="{{lastReadUrl}}">{{i18n read_more}}</a>{{/unless}}
|
||||
{{/if}}
|
||||
|
|
|
@ -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|
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue