mirror of
https://github.com/discourse/discourse.git
synced 2025-05-31 03:08:23 +08:00
DEV: move sidebar community section to database (#21166)
* DEV: move sidebar community section to database Before, community section was hard-coded. In the future, we are planning to allow admins to edit it. Therefore, it has to be moved to database to `custom_sections` table. Few steps and simplifications has to be made: - custom section was hidden behind `enable_custom_sidebar_sections` feature flag. It has to be deleted so all forums, see community section; - migration to add `section_type` column to sidebar section to show it is a special type; - migration to add `segment` column to sidebar links to determine if link should be displayed in primary section or in more section; - simplify more section to have one level only (secondary section links are merged); - ensure that links like `everything` are correctly tracking state; - make user an anonymous links position consistence. For example, from now on `faq` link for user and anonymous is visible in more tab; - delete old community-section template.
This commit is contained in:

committed by
GitHub

parent
afc1611be7
commit
709fa24558
@ -4,14 +4,6 @@ RSpec.describe SidebarSectionsController do
|
||||
fab!(:user) { Fabricate(:user) }
|
||||
fab!(:admin) { Fabricate(:admin) }
|
||||
|
||||
before do
|
||||
### TODO remove when enable_custom_sidebar_sections SiteSetting is removed
|
||||
group = Fabricate(:group)
|
||||
Fabricate(:group_user, group: group, user: user)
|
||||
Fabricate(:group_user, group: group, user: admin)
|
||||
SiteSetting.enable_custom_sidebar_sections = group.id.to_s
|
||||
end
|
||||
|
||||
describe "#index" do
|
||||
fab!(:sidebar_section) { Fabricate(:sidebar_section, title: "private section", user: user) }
|
||||
fab!(:sidebar_url_1) { Fabricate(:sidebar_url, name: "tags", value: "/tags") }
|
||||
@ -29,7 +21,7 @@ RSpec.describe SidebarSectionsController do
|
||||
get "/sidebar_sections.json"
|
||||
expect(response.status).to eq(200)
|
||||
expect(response.parsed_body["sidebar_sections"].map { |section| section["title"] }).to eq(
|
||||
["public section", "private section"],
|
||||
["Community", "public section", "private section"],
|
||||
)
|
||||
end
|
||||
end
|
||||
@ -49,6 +41,8 @@ RSpec.describe SidebarSectionsController do
|
||||
|
||||
it "creates custom section for user" do
|
||||
sign_in(user)
|
||||
expect(SidebarSection.count).to eq(1)
|
||||
|
||||
post "/sidebar_sections.json",
|
||||
params: {
|
||||
title: "custom section",
|
||||
@ -66,7 +60,7 @@ RSpec.describe SidebarSectionsController do
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
expect(SidebarSection.count).to eq(1)
|
||||
expect(SidebarSection.count).to eq(2)
|
||||
sidebar_section = SidebarSection.last
|
||||
|
||||
expect(sidebar_section.title).to eq("custom section")
|
||||
|
Reference in New Issue
Block a user