Show empty categories on categories page to people people who can edit and delete categories

This commit is contained in:
Neil Lalonde 2013-05-07 15:31:49 -04:00
parent bd99d5a40c
commit 8e24a608b0
2 changed files with 5 additions and 3 deletions

View File

@ -48,9 +48,12 @@ class CategoryList
@categories.insert(insert_at || @categories.size, uncategorized)
end
# Remove categories with no featured topics unless we have the ability to edit one
unless Guardian.new(current_user).can_create?(Category)
# Remove categories with no featured topics unless we have the ability to edit one
@categories.delete_if { |c| c.featured_topics.blank? }
else
# Show all categories to people who have the ability to edit and delete categories
@categories.insert(@categories.size, *Category.where('id not in (?)', @categories.map(&:id).compact).to_a)
end
# Get forum topic user records if appropriate

View File

@ -52,10 +52,9 @@ describe CategoryList 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 be_blank
category_list.categories.should_not be_blank
end
end