mirror of
https://github.com/discourse/discourse.git
synced 2025-03-27 09:45:43 +08:00
FIX: Hide Uncategorized unless allow_uncategorized_topics (#12889)
Uncategorized was sometimes visible even if allow_uncategorized_topics was false. This was especially happening on mobile, if at least one topic was uncategorized.
This commit is contained in:
parent
d1d9f83304
commit
77c92fd674
@ -144,7 +144,7 @@ class CategoryList
|
|||||||
|
|
||||||
def prune_empty
|
def prune_empty
|
||||||
return if SiteSetting.allow_uncategorized_topics
|
return if SiteSetting.allow_uncategorized_topics
|
||||||
@categories.delete_if { |c| c.uncategorized? && c.displayable_topics.blank? }
|
@categories.delete_if { |c| c.uncategorized? }
|
||||||
end
|
end
|
||||||
|
|
||||||
# Attach some data for serialization to each topic
|
# Attach some data for serialization to each topic
|
||||||
|
@ -67,6 +67,19 @@ describe CategoriesController do
|
|||||||
SiteSetting.get(:uncategorized_category_id), category.id
|
SiteSetting.get(:uncategorized_category_id), category.id
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'does not show uncategorized unless allow_uncategorized_topics' do
|
||||||
|
SiteSetting.desktop_category_page_style = "categories_boxes_with_topics"
|
||||||
|
|
||||||
|
uncategorized = Category.find(SiteSetting.uncategorized_category_id)
|
||||||
|
Fabricate(:topic, category: uncategorized)
|
||||||
|
CategoryFeaturedTopic.feature_topics
|
||||||
|
|
||||||
|
SiteSetting.allow_uncategorized_topics = false
|
||||||
|
|
||||||
|
get "/categories.json"
|
||||||
|
expect(response.parsed_body["category_list"]["categories"].map { |x| x['id'] }).not_to include(uncategorized.id)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'extensibility event' do
|
context 'extensibility event' do
|
||||||
@ -522,5 +535,16 @@ describe CategoriesController do
|
|||||||
expect(json['category_list']['categories'].size).to eq(4)
|
expect(json['category_list']['categories'].size).to eq(4)
|
||||||
expect(json['topic_list']['topics'].size).to eq(6)
|
expect(json['topic_list']['topics'].size).to eq(6)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'does not show uncategorized unless allow_uncategorized_topics' do
|
||||||
|
uncategorized = Category.find(SiteSetting.uncategorized_category_id)
|
||||||
|
Fabricate(:topic, category: uncategorized)
|
||||||
|
CategoryFeaturedTopic.feature_topics
|
||||||
|
|
||||||
|
SiteSetting.allow_uncategorized_topics = false
|
||||||
|
|
||||||
|
get "/categories_and_latest.json"
|
||||||
|
expect(response.parsed_body["category_list"]["categories"].map { |x| x['id'] }).not_to include(uncategorized.id)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user