logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

domain_block_spec.rb (1308B)


  1. require 'rails_helper'
  2. RSpec.describe DomainBlock, type: :model do
  3. describe 'validations' do
  4. it 'has a valid fabricator' do
  5. domain_block = Fabricate.build(:domain_block)
  6. expect(domain_block).to be_valid
  7. end
  8. it 'is invalid without a domain' do
  9. domain_block = Fabricate.build(:domain_block, domain: nil)
  10. domain_block.valid?
  11. expect(domain_block).to model_have_error_on_field(:domain)
  12. end
  13. it 'is invalid if the same normalized domain already exists' do
  14. domain_block_1 = Fabricate(:domain_block, domain: 'にゃん')
  15. domain_block_2 = Fabricate.build(:domain_block, domain: 'xn--r9j5b5b')
  16. domain_block_2.valid?
  17. expect(domain_block_2).to model_have_error_on_field(:domain)
  18. end
  19. end
  20. describe 'blocked?' do
  21. it 'returns true if the domain is suspended' do
  22. Fabricate(:domain_block, domain: 'domain', severity: :suspend)
  23. expect(DomainBlock.blocked?('domain')).to eq true
  24. end
  25. it 'returns false even if the domain is silenced' do
  26. Fabricate(:domain_block, domain: 'domain', severity: :silence)
  27. expect(DomainBlock.blocked?('domain')).to eq false
  28. end
  29. it 'returns false if the domain is not suspended nor silenced' do
  30. expect(DomainBlock.blocked?('domain')).to eq false
  31. end
  32. end
  33. end