FIX: new-topic route with sub-category and tags were broken (#12503)

https://meta.discourse.org/t/complex-url-for-creating-new-topics-results-in-server-side-error/184067/4?u=techapj
This commit is contained in:
Arpit Jalan 2021-03-24 19:54:29 +05:30 committed by GitHub
parent ee17ca9dc6
commit c449bf77b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 3 deletions

View File

@ -69,9 +69,8 @@ class TopicList < DraftableList
else
"topic_list_#{@category.url.sub(/^\//, '')}/l/#{@filter}"
end
elsif @tags
tag = @tags.first
"topic_list_tag/#{tag.name}/l/#{@filter}"
elsif @tags && @tags.first.present?
"topic_list_tag/#{@tags.first.name}/l/#{@filter}"
else
"topic_list_#{@filter}"
end

View File

@ -109,5 +109,10 @@ describe TopicList do
topic_list = TopicList.new('latest', nil, nil, tags: [tag])
expect(topic_list.preload_key).to eq("topic_list_tag/#{tag.name}/l/latest")
end
it "generates correct key when both category and tags are missing" do
topic_list = TopicList.new('latest', nil, nil, tags: Tag.none)
expect(topic_list.preload_key).to eq("topic_list_latest")
end
end
end