FEATURE: add support for top filter in tag page. (#10281)

Currently, tag pages only have the `latest` filter.
This commit is contained in:
Vinoth Kannan
2020-07-22 19:26:36 +05:30
committed by GitHub
parent db4e310376
commit 0884d570b1
5 changed files with 43 additions and 20 deletions

View File

@@ -567,6 +567,36 @@ describe TagsController do
end
end
describe '#show_top' do
fab!(:tag) { Fabricate(:tag) }
fab!(:category) { Fabricate(:category) }
fab!(:topic) { Fabricate(:topic, category: category) }
fab!(:tag_topic) { Fabricate(:topic, category: category, tags: [tag]) }
before do
SiteSetting.top_page_default_timeframe = 'all'
TopTopic.create!(topic: topic, all_score: 1)
TopTopic.create!(topic: tag_topic, all_score: 1)
end
it "can filter by tag" do
get "/tag/#{tag.name}/l/top.json"
expect(response.status).to eq(200)
topic_ids = response.parsed_body["topic_list"]["topics"].map { |topic| topic["id"] }
expect(topic_ids).to eq([tag_topic.id])
end
it "can filter by both category and tag" do
get "/tags/c/#{category.slug}/#{category.id}/#{tag.name}/l/top.json"
expect(response.status).to eq(200)
topic_ids = response.parsed_body["topic_list"]["topics"].map { |topic| topic["id"] }
expect(topic_ids).to eq([tag_topic.id])
end
end
describe '#search' do
context 'tagging disabled' do
it "returns 404" do