|
|
|
@ -3,14 +3,13 @@
|
|
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
|
|
RSpec.describe DomainBlock do
|
|
|
|
|
describe 'validations' do
|
|
|
|
|
describe 'Validations' do
|
|
|
|
|
it { is_expected.to validate_presence_of(:domain) }
|
|
|
|
|
|
|
|
|
|
it 'is invalid if the same normalized domain already exists' do
|
|
|
|
|
_domain_block = Fabricate(:domain_block, domain: 'にゃん')
|
|
|
|
|
domain_block_with_normalized_value = Fabricate.build(:domain_block, domain: 'xn--r9j5b5b')
|
|
|
|
|
domain_block_with_normalized_value.valid?
|
|
|
|
|
expect(domain_block_with_normalized_value).to model_have_error_on_field(:domain)
|
|
|
|
|
context 'when a normalized domain exists' do
|
|
|
|
|
before { Fabricate(:domain_block, domain: 'にゃん') }
|
|
|
|
|
|
|
|
|
|
it { is_expected.to_not allow_value('xn--r9j5b5b').for(:domain) }
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
@ -105,4 +104,26 @@ RSpec.describe DomainBlock do
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
describe '#policies' do
|
|
|
|
|
subject { domain_block.policies }
|
|
|
|
|
|
|
|
|
|
context 'when severity is suspend' do
|
|
|
|
|
let(:domain_block) { Fabricate.build :domain_block, severity: :suspend }
|
|
|
|
|
|
|
|
|
|
it { is_expected.to eq(%i(suspend)) }
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context 'when severity is noop' do
|
|
|
|
|
let(:domain_block) { Fabricate.build :domain_block, severity: :noop, reject_media: true }
|
|
|
|
|
|
|
|
|
|
it { is_expected.to eq(%i(reject_media)) }
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context 'when severity is silence' do
|
|
|
|
|
let(:domain_block) { Fabricate.build :domain_block, severity: :silence, reject_reports: true }
|
|
|
|
|
|
|
|
|
|
it { is_expected.to eq(%i(silence reject_reports)) }
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|