mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Respect default category sort order when navigating within app (#23270)
When navigating around, we make ajax requests with a parameter like `?filter=latest`. This results in the TopicQuery being set up with `filter: "latest"` as a string. The logic introduced in fd9a5bc0 checks for equality with `:latest` and `:unseen` symbols, which didn't work correctly in this situation
This commit makes the logic detect both strings and symbols, and adds a spec for the behaviour.
This commit is contained in:
@@ -998,6 +998,13 @@ RSpec.describe TopicQuery do
|
||||
expect(topic_ids - [topic_category.id]).to eq([topic_in_cat1.id, topic_in_cat2.id])
|
||||
end
|
||||
|
||||
it "uses the category's default sort order when filter is passed as a string" do
|
||||
category.update!(sort_order: "created", sort_ascending: true)
|
||||
topic_ids =
|
||||
TopicQuery.new(user, category: category.id, filter: "latest").list_latest.topics.map(&:id)
|
||||
expect(topic_ids - [topic_category.id]).to eq([topic_in_cat1.id, topic_in_cat2.id])
|
||||
end
|
||||
|
||||
it "should apply default sort order to latest and unseen filters only" do
|
||||
category.update!(sort_order: "created", sort_ascending: true)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user