mirror of
https://github.com/discourse/discourse.git
synced 2024-12-02 13:15:49 +08:00
c86d772277
`Rails.application.routes.recognize_path(value)` was not working for /admin paths because StaffConstraint.new requires user to check permission. This validation is not bringing much value, and the easiest way is to drop it. In the worse case scenario, a user will have an incorrect link in their sidebar. Bug reported: https://meta.discourse.org/t/custom-sidebar-sections-being-tested-on-meta/255303/66
41 lines
989 B
Ruby
41 lines
989 B
Ruby
# frozen_string_literal: true
|
|
|
|
RSpec.describe SidebarUrl do
|
|
it "validates external URLs" do
|
|
expect(
|
|
SidebarUrl.new(
|
|
icon: "link",
|
|
name: "external",
|
|
value: "https://www.test.com/discourse-test",
|
|
).valid?,
|
|
).to eq(true)
|
|
end
|
|
|
|
it "sets external flag" do
|
|
expect(
|
|
SidebarUrl.create!(icon: "link", name: "categories", value: "/categories").external,
|
|
).to be false
|
|
expect(
|
|
SidebarUrl.create!(
|
|
icon: "link",
|
|
name: "categories",
|
|
value: "http://#{Discourse.current_hostname}/categories",
|
|
).external,
|
|
).to be false
|
|
expect(
|
|
SidebarUrl.create!(
|
|
icon: "link",
|
|
name: "categories",
|
|
value: "https://#{Discourse.current_hostname}/categories",
|
|
).external,
|
|
).to be false
|
|
expect(
|
|
SidebarUrl.create!(
|
|
icon: "link",
|
|
name: "categories",
|
|
value: "https://www.test.com/discourse-test",
|
|
).external,
|
|
).to be true
|
|
end
|
|
end
|