mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 03:09:00 +08:00
DEV: Regression test for categories N+1 (#26204)
This commit is contained in:
parent
531e33b303
commit
1fbcc6936c
|
@ -314,6 +314,31 @@ RSpec.describe CategoriesController do
|
|||
expect(category_response["subcategory_list"][0]["id"]).to eq(subcategory.id)
|
||||
end
|
||||
|
||||
it "doesn't do more queries when more categories exist" do
|
||||
SiteSetting.lazy_load_categories_groups = true
|
||||
Theme.cache.clear
|
||||
|
||||
Fabricate(:category, parent_category: Fabricate(:category))
|
||||
|
||||
before_queries =
|
||||
track_sql_queries do
|
||||
get "/categories.json"
|
||||
expect(response.status).to eq(200)
|
||||
end
|
||||
|
||||
Fabricate(:category, parent_category: Fabricate(:category))
|
||||
|
||||
Theme.cache.clear
|
||||
|
||||
after_queries =
|
||||
track_sql_queries do
|
||||
get "/categories.json"
|
||||
expect(response.status).to eq(200)
|
||||
end
|
||||
|
||||
expect(after_queries.size).to eq(before_queries.size)
|
||||
end
|
||||
|
||||
it "does not result in N+1 queries problem with multiple topics" do
|
||||
category1 = Fabricate(:category)
|
||||
category2 = Fabricate(:category)
|
||||
|
|
Loading…
Reference in New Issue
Block a user