mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 08:09:33 +08:00
6e161d3e75
The most common thing that we do with fab! is: fab!(:thing) { Fabricate(:thing) } This commit adds a shorthand for this which is just simply: fab!(:thing) i.e. If you omit the block, then, by default, you'll get a `Fabricate`d object using the fabricator of the same name.
40 lines
1.1 KiB
Ruby
40 lines
1.1 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
RSpec.describe SidebarSection do
|
|
fab!(:user)
|
|
fab!(:sidebar_section) { Fabricate(:sidebar_section, user: user) }
|
|
let(:community_section) do
|
|
SidebarSection.find_by(section_type: SidebarSection.section_types[:community])
|
|
end
|
|
|
|
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
|
|
|
|
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!
|
|
|
|
expect(community_section.reload.title).to eq("Community")
|
|
|
|
expect(community_section.sidebar_section_links.all.map { |link| link.linkable.name }).to eq(
|
|
[
|
|
"Topics",
|
|
"My Posts",
|
|
"Review",
|
|
"Admin",
|
|
"Admin Revamp",
|
|
"Users",
|
|
"About",
|
|
"FAQ",
|
|
"Groups",
|
|
"Badges",
|
|
],
|
|
)
|
|
end
|
|
end
|