FEATURE: Paginate categories when there are many (#29569)

This commit removes the new optimized category style introduced in
previous commits (d37a0d40, 9a80d718 and 430c42ac), in favour of the
existent `categories_only`.
This commit is contained in:
Bianca Nenciu
2024-11-11 17:32:45 +02:00
committed by GitHub
parent 8854a7101b
commit f1700ca589
13 changed files with 23 additions and 323 deletions

View File

@ -404,7 +404,7 @@ RSpec.describe CategoriesController do
let!(:category2) { Fabricate(:category, user: admin) }
let!(:category3) { Fabricate(:category, user: admin) }
it "paginates results wihen lazy_load_categories is enabled" do
it "paginates results when lazy_load_categories is enabled" do
SiteSetting.lazy_load_categories_groups = "#{Group::AUTO_GROUPS[:everyone]}"
stub_const(CategoryList, "CATEGORIES_PER_PAGE", 2) { get "/categories.json?page=1" }
@ -416,16 +416,16 @@ RSpec.describe CategoriesController do
expect(response.parsed_body["category_list"]["categories"].count).to eq(2)
end
it "paginates results wihen desktop_category_page_style is categories_only_optimized" do
SiteSetting.desktop_category_page_style = "categories_only_optimized"
it "paginates results when there are many categories" do
stub_const(CategoryList, "MAX_UNOPTIMIZED_CATEGORIES", 2) do
stub_const(CategoryList, "CATEGORIES_PER_PAGE", 2) { get "/categories.json?page=1" }
expect(response.status).to eq(200)
expect(response.parsed_body["category_list"]["categories"].count).to eq(2)
stub_const(CategoryList, "CATEGORIES_PER_PAGE", 2) { get "/categories.json?page=1" }
expect(response.status).to eq(200)
expect(response.parsed_body["category_list"]["categories"].count).to eq(2)
stub_const(CategoryList, "CATEGORIES_PER_PAGE", 2) { get "/categories.json?page=2" }
expect(response.status).to eq(200)
expect(response.parsed_body["category_list"]["categories"].count).to eq(2)
stub_const(CategoryList, "CATEGORIES_PER_PAGE", 2) { get "/categories.json?page=2" }
expect(response.status).to eq(200)
expect(response.parsed_body["category_list"]["categories"].count).to eq(2)
end
end
it "does not paginate results by default" do