about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAkihiko Odaki (@fn_aki@pawoo.net) <akihiko.odaki.4i@stu.hosei.ac.jp>2017-06-19 18:31:27 +0900
committerEugen Rochko <eugen@zeonfederated.com>2017-06-19 11:31:27 +0200
commit6eefccdacc96161d06ce38070002b7d0ce582aee (patch)
tree16830ee96b717ef3a6ab5bccbf961bc365e32a49
parent29a22691d2a9eefbc2eb886659843f87d187c98e (diff)
Cover DomainBlock more (#3838)
-rw-r--r--spec/models/domain_block_spec.rb22
1 files changed, 19 insertions, 3 deletions
diff --git a/spec/models/domain_block_spec.rb b/spec/models/domain_block_spec.rb
index b19c8083e..89cadccfe 100644
--- a/spec/models/domain_block_spec.rb
+++ b/spec/models/domain_block_spec.rb
@@ -13,11 +13,27 @@ RSpec.describe DomainBlock, type: :model do
       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')
+    it 'is invalid if the same normalized domain already exists' do
+      domain_block_1 = Fabricate(:domain_block, domain: 'にゃん')
+      domain_block_2 = Fabricate.build(:domain_block, domain: 'xn--r9j5b5b')
       domain_block_2.valid?
       expect(domain_block_2).to model_have_error_on_field(:domain)
     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