mirror of
https://github.com/discourse/discourse.git
synced 2024-12-11 16:13:44 +08:00
c9dab6fd08
It's very easy to forget to add `require 'rails_helper'` at the top of every core/plugin spec file, and omissions can cause some very confusing/sporadic errors. By setting this flag in `.rspec`, we can remove the need for `require 'rails_helper'` entirely.
26 lines
1.1 KiB
Ruby
26 lines
1.1 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
describe Onebox::DomainChecker do
|
|
describe '.is_blocked?' do
|
|
before do
|
|
SiteSetting.blocked_onebox_domains = "api.cat.org|kitten.cloud"
|
|
end
|
|
|
|
describe "returns true when entirely matched" do
|
|
it { expect(described_class.is_blocked?("api.cat.org")).to be(true) }
|
|
it { expect(described_class.is_blocked?("kitten.cloud")).to be(true) }
|
|
it { expect(described_class.is_blocked?("api.dog.org")).to be(false) }
|
|
it { expect(described_class.is_blocked?("puppy.cloud")).to be(false) }
|
|
end
|
|
|
|
describe "returns true when ends with .<domain>" do
|
|
it { expect(described_class.is_blocked?("dev.api.cat.org")).to be(true) }
|
|
it { expect(described_class.is_blocked?(".api.cat.org")).to be(true) }
|
|
it { expect(described_class.is_blocked?("dev.kitten.cloud")).to be(true) }
|
|
it { expect(described_class.is_blocked?(".kitten.cloud")).to be(true) }
|
|
it { expect(described_class.is_blocked?("xapi.cat.org")).to be(false) }
|
|
it { expect(described_class.is_blocked?("xkitten.cloud")).to be(false) }
|
|
end
|
|
end
|
|
end
|