You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
745 B

  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 domain already exists' do
  14. domain_block_1 = Fabricate(:domain_block, domain: 'dalek.com')
  15. domain_block_2 = Fabricate.build(:domain_block, domain: 'dalek.com')
  16. domain_block_2.valid?
  17. expect(domain_block_2).to model_have_error_on_field(:domain)
  18. end
  19. end
  20. end