mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: add support for top filter in tag page. (#10281)
Currently, tag pages only have the `latest` filter.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user