discourse/spec/models/sidebar_section_spec.rb
Osama Sayegh 19672faba6
Some checks are pending
Licenses / run (push) Waiting to run
Linting / run (push) Waiting to run
Tests / ${{ matrix.target }} ${{ matrix.build_type }} (system, plugins) (push) Waiting to run
Tests / ${{ matrix.target }} ${{ matrix.build_type }} (system, themes) (push) Waiting to run
Tests / ${{ matrix.target }} ${{ matrix.build_type }} (annotations, core) (push) Waiting to run
Tests / ${{ matrix.target }} ${{ matrix.build_type }} (backend, core) (push) Waiting to run
Tests / ${{ matrix.target }} ${{ matrix.build_type }} (backend, plugins) (push) Waiting to run
Tests / ${{ matrix.target }} ${{ matrix.build_type }} (frontend, plugins) (push) Waiting to run
Tests / ${{ matrix.target }} ${{ matrix.build_type }} (frontend, themes) (push) Waiting to run
Tests / ${{ matrix.target }} ${{ matrix.build_type }} (system, chat) (push) Waiting to run
Tests / ${{ matrix.target }} ${{ matrix.build_type }} (system, core) (push) Waiting to run
Tests / core frontend (${{ matrix.browser }}) (Chrome) (push) Waiting to run
Tests / core frontend (${{ matrix.browser }}) (Firefox ESR) (push) Waiting to run
Tests / core frontend (${{ matrix.browser }}) (Firefox Evergreen) (push) Waiting to run
FEATURE: Add invite link to the sidebar (#29448)
This commit adds a new "Invite" link to the sidebar for all users who can invite to the site. Clicking the link opens the invite modal without changing the current route the user is on. Admins can customize the new link or remove it entirely if they wish by editing the sidebar section.

Internal topic: t/129752.
2024-10-30 05:31:14 +03:00

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",
"Invite",
"Users",
"About",
"FAQ",
"Groups",
"Badges",
],
)
end
end