diff --git a/app/models/category_list.rb b/app/models/category_list.rb index 9883767c7..4d4d4c254 100644 --- a/app/models/category_list.rb +++ b/app/models/category_list.rb @@ -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 diff --git a/spec/components/category_list_spec.rb b/spec/components/category_list_spec.rb index 540e60742..4b224254c 100644 --- a/spec/components/category_list_spec.rb +++ b/spec/components/category_list_spec.rb @@ -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