mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Preload user-specific category fields (#25663)
This is used when lazy_load_categories is enabled to fetch more info about the category.
This commit is contained in:
@@ -1041,6 +1041,7 @@ RSpec.describe CategoriesController do
|
||||
end
|
||||
|
||||
describe "#find" do
|
||||
fab!(:group)
|
||||
fab!(:category) { Fabricate(:category, name: "Foo") }
|
||||
fab!(:subcategory) { Fabricate(:category, name: "Foobar", parent_category: category) }
|
||||
|
||||
@@ -1051,6 +1052,17 @@ RSpec.describe CategoriesController do
|
||||
expect(response.parsed_body["categories"].map { |c| c["id"] }).to eq([subcategory.id])
|
||||
end
|
||||
|
||||
it "preloads user-specific fields" do
|
||||
subcategory.update!(read_restricted: true)
|
||||
|
||||
get "/categories/find.json", params: { ids: [category.id] }
|
||||
|
||||
serialized = response.parsed_body["categories"].first
|
||||
expect(serialized["notification_level"]).to eq(CategoryUser.default_notification_level)
|
||||
expect(serialized["permission"]).to eq(nil)
|
||||
expect(serialized["has_children"]).to eq(false)
|
||||
end
|
||||
|
||||
it "does not return hidden category" do
|
||||
category.update!(read_restricted: true)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user