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