2023-02-02 22:44:40 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
RSpec.describe SidebarUrl do
|
2023-03-31 01:26:56 -04:00
|
|
|
it "validates external URLs" do
|
2023-03-08 18:44:54 -05:00
|
|
|
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
|
2023-02-02 22:44:40 -05:00
|
|
|
end
|
|
|
|
end
|