FIX: Topics not always properly shown (#11)
There was a bug with the logic in how we were checking for matching tags and categories in KE settings. If only tags were set, topics would not show.
This commit is contained in:
parent
500ccf9656
commit
22c2387b76
|
@ -55,6 +55,7 @@ module KnowledgeExplorer
|
|||
|
||||
def topic_in_explorer(category, tags)
|
||||
category_match = KnowledgeExplorer::Query.categories.include?(category.to_s)
|
||||
tags = tags.pluck(:name)
|
||||
tag_match = KnowledgeExplorer::Query.tags.any? { |tag| tags.include?(tag) }
|
||||
|
||||
category_match || tag_match
|
||||
|
|
|
@ -154,6 +154,22 @@ describe KnowledgeExplorer::KnowledgeExplorerController do
|
|||
|
||||
expect(response.parsed_body['topic']).to be_blank
|
||||
end
|
||||
|
||||
it 'should return a KE topic when only tags are added to settings' do
|
||||
SiteSetting.knowledge_explorer_categories = nil
|
||||
|
||||
get "/docs.json?topic=#{topic.id}"
|
||||
|
||||
expect(response.parsed_body['topic']['id']).to eq(topic.id)
|
||||
end
|
||||
|
||||
it 'should return a KE topic when only categories are added to settings' do
|
||||
SiteSetting.knowledge_explorer_tags = nil
|
||||
|
||||
get "/docs.json?topic=#{topic.id}"
|
||||
|
||||
expect(response.parsed_body['topic']['id']).to eq(topic.id)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue