2023-04-05 08:52:18 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
RSpec.describe SidebarSection do
|
|
|
|
fab!(:user) { Fabricate(:user) }
|
|
|
|
fab!(:sidebar_section) { Fabricate(:sidebar_section, user: user) }
|
2023-05-23 07:53:32 +08:00
|
|
|
let(:community_section) do
|
|
|
|
SidebarSection.find_by(section_type: SidebarSection.section_types[:community])
|
|
|
|
end
|
2023-04-05 08:52:18 +08:00
|
|
|
|
|
|
|
it "uses system user for public sections" do
|
|
|
|
expect(sidebar_section.user_id).to eq(user.id)
|
|
|
|
sidebar_section.update!(public: true)
|
|
|
|
expect(sidebar_section.user_id).to eq(Discourse.system_user.id)
|
|
|
|
end
|
2023-05-23 07:53:32 +08:00
|
|
|
|
|
|
|
it "resets Community section to the default state" do
|
|
|
|
community_section.update!(title: "test")
|
|
|
|
community_section.sidebar_section_links.first.linkable.update!(name: "everything edited")
|
|
|
|
community_section.sidebar_section_links.last.destroy!
|
|
|
|
community_section.reset_community!
|
2023-05-25 09:10:32 +08:00
|
|
|
|
2023-05-23 07:53:32 +08:00
|
|
|
expect(community_section.reload.title).to eq("Community")
|
2023-05-25 09:10:32 +08:00
|
|
|
|
2023-05-23 07:53:32 +08:00
|
|
|
expect(community_section.sidebar_section_links.all.map { |link| link.linkable.name }).to eq(
|
2023-06-15 09:36:38 +08:00
|
|
|
["Topics", "My Posts", "Review", "Admin", "Users", "About", "FAQ", "Groups", "Badges"],
|
2023-05-23 07:53:32 +08:00
|
|
|
)
|
|
|
|
end
|
2023-04-05 08:52:18 +08:00
|
|
|
end
|