about summary refs log tree commit diff
path: root/spec/models/domain_block_spec.rb
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2017-04-05 03:31:45 +0200
committerEugen Rochko <eugen@zeonfederated.com>2017-04-05 03:31:45 +0200
commitccb6a658fd1a2e596c95d5b8e7a39f72a5f5b14b (patch)
tree7b846b51e3c91fb93aa379361dfe7a811bf5a01c /spec/models/domain_block_spec.rb
parent94d00f278819d34ef97d59d17eb289e9be217dfe (diff)
parent667ffafef8c8b7956cdd31b8f65d5e82778211d8 (diff)
Merge branch 'fakenine-add_more_tests_to_models'
Diffstat (limited to 'spec/models/domain_block_spec.rb')
-rw-r--r--spec/models/domain_block_spec.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/spec/models/domain_block_spec.rb b/spec/models/domain_block_spec.rb
index ad5403110..b19c8083e 100644
--- a/spec/models/domain_block_spec.rb
+++ b/spec/models/domain_block_spec.rb
@@ -1,5 +1,23 @@
 require 'rails_helper'
 
 RSpec.describe DomainBlock, type: :model do
+  describe 'validations' do
+    it 'has a valid fabricator' do
+      domain_block = Fabricate.build(:domain_block)
+      expect(domain_block).to be_valid
+    end
 
+    it 'is invalid without a domain' do
+      domain_block = Fabricate.build(:domain_block, domain: nil)
+      domain_block.valid?
+      expect(domain_block).to model_have_error_on_field(:domain)
+    end
+
+    it 'is invalid if the domain already exists' do
+      domain_block_1 = Fabricate(:domain_block, domain: 'dalek.com')
+      domain_block_2 = Fabricate.build(:domain_block, domain: 'dalek.com')
+      domain_block_2.valid?
+      expect(domain_block_2).to model_have_error_on_field(:domain)
+    end
+  end
 end