discourse/spec/models/sidebar_url_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

41 lines
989 B
Ruby
Raw Normal View History

# 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