0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-09 21:45:25 +08:00
discourse/spec/serializers/admin_category_serializer_spec.rb
Martin Brennan d9dfa85e1b
FEATURE: Category management UI for admins (#41218)
Adds a new `/admin/config/category-management` route which shows
the admin filterable lists of each registered category type, as well as
an "All categories" tab which shows all categories regardless of type,
including badges to indicate type.

This makes it a lot easier for admins to find which of their categories
are configured for each type, and jump to the settings for those
categories:

<img width="2898" height="1488" alt="image"
src="https://github.com/user-attachments/assets/8687a18c-6279-4e66-b3ff-e5694e157430"
/>

<img width="2852" height="1376" alt="image"
src="https://github.com/user-attachments/assets/8e9726b5-c268-400b-9764-451c536695c3"
/>

---------

Co-authored-by: awesomerobot <kris.aubuchon@discourse.org>
2026-07-15 09:17:25 +10:00

25 lines
918 B
Ruby
Vendored

# frozen_string_literal: true
RSpec.describe AdminCategorySerializer do
fab!(:admin)
it "serializes admin category management data" do
parent = Fabricate(:category, name: "Knowledge", slug: "knowledge")
child = Fabricate(:category, name: "Guides", slug: "guides", parent_category: parent)
serialized = described_class.new(child, scope: Guardian.new(admin), root: false).as_json
expect(serialized).to include(
id: child.id,
badge_chain: [
a_hash_including(id: parent.id, name: "Knowledge", parent_category_id: nil),
a_hash_including(id: child.id, name: "Guides", parent_category_id: parent.id),
],
category_types: [a_hash_including(id: :discussion, name: "Discussion")],
description_text: child.description_text,
read_restricted: false,
topic_count: child.topic_count,
edit_url: "/c/knowledge/guides/edit/general",
)
end
end