Show empty categories with descriptions to everyone

This commit is contained in:
Neil Lalonde 2013-08-22 11:55:20 -04:00
parent ae93fcebde
commit 24617dd776
2 changed files with 8 additions and 2 deletions

View File

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

View File

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