mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: my links in sidebar section (#20754)
Links like `/my/preferences` were invalid in custom section. The reason is that `/my` links are just redirects from backend, and they are not recognized as valid Ember paths. https://github.com/discourse/discourse/blob/main/config/routes.rb#L433 Therefore, regex match allowlist was added - similar to backend check: https://github.com/discourse/discourse/blob/main/app/controllers/users_controller.rb#L471 /safe-mode is same case
This commit is contained in:
committed by
GitHub
parent
ae939f4111
commit
1859025228
@@ -61,6 +61,7 @@ RSpec.describe SidebarSectionsController do
|
||||
},
|
||||
{ icon: "address-book", name: "tags", value: "/tags" },
|
||||
{ icon: "external-link-alt", name: "Discourse", value: "https://discourse.org" },
|
||||
{ icon: "external-link-alt", name: "My preferences", value: "/my/preferences" },
|
||||
],
|
||||
}
|
||||
|
||||
@@ -73,7 +74,7 @@ RSpec.describe SidebarSectionsController do
|
||||
expect(sidebar_section.user).to eq(user)
|
||||
expect(sidebar_section.public).to be false
|
||||
expect(UserHistory.count).to eq(0)
|
||||
expect(sidebar_section.sidebar_urls.count).to eq(3)
|
||||
expect(sidebar_section.sidebar_urls.count).to eq(4)
|
||||
expect(sidebar_section.sidebar_urls.first.icon).to eq("link")
|
||||
expect(sidebar_section.sidebar_urls.first.name).to eq("categories")
|
||||
expect(sidebar_section.sidebar_urls.first.value).to eq("/categories")
|
||||
@@ -86,6 +87,10 @@ RSpec.describe SidebarSectionsController do
|
||||
expect(sidebar_section.sidebar_urls.third.name).to eq("Discourse")
|
||||
expect(sidebar_section.sidebar_urls.third.value).to eq("https://discourse.org")
|
||||
expect(sidebar_section.sidebar_urls.third.external).to be true
|
||||
expect(sidebar_section.sidebar_urls.fourth.icon).to eq("external-link-alt")
|
||||
expect(sidebar_section.sidebar_urls.fourth.name).to eq("My preferences")
|
||||
expect(sidebar_section.sidebar_urls.fourth.value).to eq("/my/preferences")
|
||||
expect(sidebar_section.sidebar_urls.fourth.external).to be false
|
||||
end
|
||||
|
||||
it "does not allow regular user to create public section" do
|
||||
|
||||
@@ -34,6 +34,25 @@ describe "Custom sidebar sections", type: :system, js: true do
|
||||
expect(sidebar).to have_link("Sidebar Tags")
|
||||
end
|
||||
|
||||
it "allows the user to create custom section with /my link" do
|
||||
visit("/latest")
|
||||
sidebar.open_new_custom_section
|
||||
|
||||
expect(section_modal).to be_visible
|
||||
expect(section_modal).to have_disabled_save
|
||||
expect(sidebar.custom_section_modal_title).to have_content("Add custom section")
|
||||
|
||||
section_modal.fill_name("My section")
|
||||
|
||||
section_modal.fill_link("My preferences", "/my/preferences")
|
||||
expect(section_modal).to have_enabled_save
|
||||
|
||||
section_modal.save
|
||||
|
||||
expect(page).to have_button("My section")
|
||||
expect(sidebar).to have_link("My preferences")
|
||||
end
|
||||
|
||||
it "allows the user to create custom section with external link" do
|
||||
visit("/latest")
|
||||
sidebar.open_new_custom_section
|
||||
|
||||
Reference in New Issue
Block a user