diff --git a/app/models/category_list.rb b/app/models/category_list.rb index 712adab190c..94dd860a093 100644 --- a/app/models/category_list.rb +++ b/app/models/category_list.rb @@ -115,7 +115,7 @@ class CategoryList def prune_empty unless @guardian.can_create?(Category) # Remove categories with no featured topics unless we have the ability to edit one - @categories.delete_if { |c| c.displayable_topics.blank? } + @categories.delete_if { |c| c.displayable_topics.blank? && c.description.nil? } end end diff --git a/spec/components/category_list_spec.rb b/spec/components/category_list_spec.rb index e561df9f25d..ef27f65e17d 100644 --- a/spec/components/category_list_spec.rb +++ b/spec/components/category_list_spec.rb @@ -61,11 +61,17 @@ describe CategoryList do category_list.categories.should be_blank end - it "returns empty the empty for those who can create them" do + it "returns empty categories for those who can create them" do Guardian.any_instance.expects(:can_create?).with(Category).returns(true) category_list.categories.should_not be_blank end + it "returns empty categories with descriptions" do + Fabricate(:category, description: 'The category description.') + Guardian.any_instance.expects(:can_create?).with(Category).returns(false) + category_list.categories.should_not be_blank + end + it 'returns the empty category and a non-empty category for those who can create them' do category_with_topics = Fabricate(:topic, category: Fabricate(:category)) Guardian.any_instance.expects(:can_create?).with(Category).returns(true)