2023-04-04 19:52:18 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
RSpec.describe SidebarSection do
|
2023-11-09 16:47:59 -06:00
|
|
|
fab!(:user)
|
2023-04-04 19:52:18 -05:00
|
|
|
fab!(:sidebar_section) { Fabricate(:sidebar_section, user: user) }
|
2023-05-22 18:53:32 -05:00
|
|
|
let(:community_section) do
|
|
|
|
SidebarSection.find_by(section_type: SidebarSection.section_types[:community])
|
|
|
|
end
|
2023-04-04 19:52:18 -05: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-22 18:53:32 -05: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-24 20:10:32 -05:00
|
|
|
|
2023-05-22 18:53:32 -05:00
|
|
|
expect(community_section.reload.title).to eq("Community")
|
2023-05-24 20:10:32 -05:00
|
|
|
|
2023-05-22 18:53:32 -05:00
|
|
|
expect(community_section.sidebar_section_links.all.map { |link| link.linkable.name }).to eq(
|
2024-10-29 21:31:14 -05:00
|
|
|
[
|
|
|
|
"Topics",
|
|
|
|
"My Posts",
|
|
|
|
"Review",
|
|
|
|
"Admin",
|
|
|
|
"Invite",
|
|
|
|
"Users",
|
|
|
|
"About",
|
|
|
|
"FAQ",
|
|
|
|
"Groups",
|
|
|
|
"Badges",
|
|
|
|
],
|
2023-05-22 18:53:32 -05:00
|
|
|
)
|
|
|
|
end
|
2023-04-04 19:52:18 -05:00
|
|
|
end
|