A platform for community discussion. Free, open, simple.
FIX: Serialize parent categories first (#24530)
Bianca Nenciu012541b04588
diff --git a/app/models/topic_list.rb b/app/models/topic_list.rbindex 1071f573741..6061747eee5 100644--- a/app/models/topic_list.rb+++ b/app/models/topic_list.rb@@ -78,7 +78,7 @@ class TopicListdef categories@categories ||=- topics.map { |t| [t.category, t.category&.parent_category] }.uniq.flatten.compact+ topics.map { |t| [t.category&.parent_category, t.category] }.uniq.flatten.compactenddef load_topicsdiff --git a/spec/requests/list_controller_spec.rb b/spec/requests/list_controller_spec.rbindex 0565cd53a03..db9d9f02c66 100644--- a/spec/requests/list_controller_spec.rb+++ b/spec/requests/list_controller_spec.rb@@ -239,9 +239,9 @@ RSpec.describe ListController doexpect(response.parsed_body["topic_list"]["topics"].length).to eq(1)expect(response.parsed_body["topic_list"]["topics"][0]["id"]).to eq(topic.id)expect(response.parsed_body["topic_list"]["categories"].length).to eq(2)- expect(- response.parsed_body["topic_list"]["categories"].map { |c| c["id"] },- ).to contain_exactly(category.id, subcategory.id)+ expect(response.parsed_body["topic_list"]["categories"].map { |c| c["id"] }).to eq(+ [category.id, subcategory.id],+ )endit "does not return categories if not true" do