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