From bfdbf373f360c977db183b533a9ff94f9af1e7f2 Mon Sep 17 00:00:00 2001 From: Neil Lalonde Date: Fri, 21 Jun 2013 11:36:00 -0400 Subject: [PATCH] Don't show invisible topics in uncategorized on categories page --- app/models/category_list.rb | 1 + spec/components/category_list_spec.rb | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/models/category_list.rb b/app/models/category_list.rb index 5690130bc..fd3d89231 100644 --- a/app/models/category_list.rb +++ b/app/models/category_list.rb @@ -68,6 +68,7 @@ class CategoryList # Support for uncategorized topics uncategorized_topics = Topic .listable_topics + .visible .where(category_id: nil) .topic_list_order .limit(SiteSetting.category_featured_topics) diff --git a/spec/components/category_list_spec.rb b/spec/components/category_list_spec.rb index b3903a630..a6eb8515e 100644 --- a/spec/components/category_list_spec.rb +++ b/spec/components/category_list_spec.rb @@ -12,7 +12,7 @@ describe CategoryList do category_list.categories.should be_blank end - context "with an uncateorized topic" do + context "with an uncategorized topic" do let!(:topic) { Fabricate(:topic)} let(:category) { category_list.categories.first } @@ -24,6 +24,12 @@ describe CategoryList do category.featured_topics.should == [topic] end + it 'does not return an invisible topic' do + invisible_topic = Fabricate(:topic) + invisible_topic.update_status('visible', false, Fabricate(:admin)) + expect(category.featured_topics).to_not include(invisible_topic) + end + end end