mirror of
https://github.com/discourse/discourse.git
synced 2024-11-24 03:42:16 +08:00
Show empty categories on categories page to people people who can edit and delete categories
This commit is contained in:
parent
bd99d5a40c
commit
8e24a608b0
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user