Cover DomainBlock more (#3838)
This commit is contained in:
parent
29a22691d2
commit
6eefccdacc
@ -13,11 +13,27 @@ RSpec.describe DomainBlock, type: :model do
|
|||||||
expect(domain_block).to model_have_error_on_field(:domain)
|
expect(domain_block).to model_have_error_on_field(:domain)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'is invalid if the domain already exists' do
|
it 'is invalid if the same normalized domain already exists' do
|
||||||
domain_block_1 = Fabricate(:domain_block, domain: 'dalek.com')
|
domain_block_1 = Fabricate(:domain_block, domain: 'にゃん')
|
||||||
domain_block_2 = Fabricate.build(:domain_block, domain: 'dalek.com')
|
domain_block_2 = Fabricate.build(:domain_block, domain: 'xn--r9j5b5b')
|
||||||
domain_block_2.valid?
|
domain_block_2.valid?
|
||||||
expect(domain_block_2).to model_have_error_on_field(:domain)
|
expect(domain_block_2).to model_have_error_on_field(:domain)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'blocked?' do
|
||||||
|
it 'returns true if the domain is suspended' do
|
||||||
|
Fabricate(:domain_block, domain: 'domain', severity: :suspend)
|
||||||
|
expect(DomainBlock.blocked?('domain')).to eq true
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns false even if the domain is silenced' do
|
||||||
|
Fabricate(:domain_block, domain: 'domain', severity: :silence)
|
||||||
|
expect(DomainBlock.blocked?('domain')).to eq false
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns false if the domain is not suspended nor silenced' do
|
||||||
|
expect(DomainBlock.blocked?('domain')).to eq false
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user