Skip to content

Commit 24617dd

Browse files
committed
Show empty categories with descriptions to everyone
1 parent ae93fce commit 24617dd

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

app/models/category_list.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def add_uncategorized
115115
def prune_empty
116116
unless @guardian.can_create?(Category)
117117
# Remove categories with no featured topics unless we have the ability to edit one
118-
@categories.delete_if { |c| c.displayable_topics.blank? }
118+
@categories.delete_if { |c| c.displayable_topics.blank? && c.description.nil? }
119119
end
120120
end
121121

spec/components/category_list_spec.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,17 @@
6161
category_list.categories.should be_blank
6262
end
6363

64-
it "returns empty the empty for those who can create them" do
64+
it "returns empty categories for those who can create them" do
6565
Guardian.any_instance.expects(:can_create?).with(Category).returns(true)
6666
category_list.categories.should_not be_blank
6767
end
6868

69+
it "returns empty categories with descriptions" do
70+
Fabricate(:category, description: 'The category description.')
71+
Guardian.any_instance.expects(:can_create?).with(Category).returns(false)
72+
category_list.categories.should_not be_blank
73+
end
74+
6975
it 'returns the empty category and a non-empty category for those who can create them' do
7076
category_with_topics = Fabricate(:topic, category: Fabricate(:category))
7177
Guardian.any_instance.expects(:can_create?).with(Category).returns(true)

0 commit comments

Comments
 (0)